Yes it is possible to populate your dbGrid with out using a data control. I prefer to use an ADO connection (Coded not the control) toconnect to the database. From there I use SQL to select the desired fields.
This is just a quick example & may not be exact. It's quitting time now. If you need more help just post & I'll reply asap...Code:'Query by Chemical Name Sub cmdQueryChemical_Click() Dim cnnLabTracking As New Connection Dim rsChemicalName As Recordset Dim cmd1 As Command Dim str1 As String Dim fldLoop As ADODB.Field Set cmd1 = New ADODB.Command With cmd1 .ActiveConnection = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=C:\My Documents\Access Files\Lab Tracking.mdb;" .CommandText = "SELECT SampleNumber, `Chemical Name`, `Container Number`, `Container Weight`," & _ "`Description`, `Part Number`, `Batch`, `Screener`, `Department`, `Operator`," & _ "`Date` " & _ "FROM SampleLogin " & _ .CommandType = adCmdText End With 'Run query. cmd1.Execute 'Clear data grid vfgSearchResults.Clear 'Open recordset on cmd1 Set rsChemicalName = New ADODB.Recordset rsChemicalName.Open cmd1 Do Until rsChemicalName.EOF vfgSearchResults.AddItem str1, 0 str1 = "" For Each fldLoop In rsChemicalName.Fields str1 = str1 & fldLoop.Value & Chr(9) Next fldLoop vfgSearchResults.Refresh Debug.Print str1 rsChemicalName.MoveNext Loop rsChemicalName.Close End Sub




Reply With Quote