-
using access 2000, i am trying to pass the results of a sql statement to a data grid control (or a flexgrid control if it is more convenient). from there, i want the user to be able to select the appropriate record which will then be displayed on the original form. unfortunately, i'm not quite sure how to get the data grid to display my results. does anyone have any suggestions?
-
If you use the MSFlexGrid Control you could try something similar to the following.
Code:
Dim cnn As Connection
Dim rs As Recordset
Dim cmd1 As New ADODB.Command
Dim str1 As String
Dim fldLoop As ADODB.Field
With cmd1
.ActiveConnection = _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\\My Documents\Access Files\*.mdb;"
.CommandText = "SELECT `*` FROM `TableName`"
.CommandType = adCmdText
End With
'Run Query
cmd1.Execute
'Open Recorset on cmd1
rs.Open cmd1
Do Until rs.EOF
str1 = ""
For Each fldLoop In rs.Fields
str1 = str1 & fldLoop.Value
Next fldLoop
MSFlexGrid1.AddItem str1
rs.MoveNext
Loop
rs.Close