PDA

Click to See Complete Forum and Search --> : HELP with MSFlexGrid!!


paul
Aug 29th, 1999, 05:12 AM
Hi
I am trying to use a MSFlexGrid to display data from a MSAccess database.
Here is my code. I cant get the grid to show the results.I am very NEW to VB
and any help would be appreciated.
Thanks

Private Sub Command1_Click()

Dim strSQL As String
strSQL = "SELECT * FROM Customer " & _
"WHERE (HomePhone = """ & varHomePhone & """);"
Me.Data2.RecordSource = strSQL
Me.Data2.Refresh

Dim strSQL1 As String
Dim strKey1 As String
strKey = Text1.Text
strSQL = "SELECT * FROM Orders " & _
"WHERE (CustomerID = """ & strKey1 & """);"
Me.Data1.RecordSource = strSQL1
Me.Data2.Refresh
Me.MSFlexGrid1.Refresh
End Sub

mcleran
Aug 30th, 1999, 05:56 PM
I can't really follow the code that you've posted. Here's how I've used the MSHFlexGrid:
1. Use ADO to open a recordset
2. Set the recordset property of the MSHFlexGrid to the ADO recordset.

Dim acon as ADODB.Connection
Dim arec as ADODB.Recordset

'set SQL query
sSQL = string for SQL query

'instantiate connection & recordset objects
Set acon = New ADODB.Connection
Set arec = New ADODB.Recordset

'define connect string
sConnectString = connect string to data source

'make a connection
acon.Open (sConnectString)

'get the recordset
arec.Open sSQL, acon, adoCursor, adoLocking

'set MSHFlexGrid recordset property
Set MSHFlexGrid.Recordset = arec

SmithVoice
Aug 30th, 1999, 09:38 PM
Sorry if this seems silly but have you set the flex's DataMode to bound and the Datasource property to the datacontrol?

Then refreshing the datacontrol should refil the grid if there are records in the set.

-S

------------------
http://www.smithvoice.com/vbfun.htm