Click to See Complete Forum and Search --> : Combobox in dbGrid


Marcus Human
March 15th, 2001, 12:53 AM
I need to add a combobox or listbox to a dbGrid in VB6 to lookup fields(MSACCESS)in table X and after selection of the particular field it must dump the selection in table Y.
Is this possible and how?
Thanks

robby bassic
March 15th, 2001, 01:20 PM
'Reference: Microsoft ActiveX Data Objects 2.5 Library

'//////////Place this section at top of form
Private WithEvents rsADOSetRecord As ADODB.Recordset
Private adoDataGrid As ADODB.Connection
'/////////////

Private Sub sbLoadCombo()
Set adoDataGrid = New ADODB.Connection
Set rsADOSetRecord = New ADODB.Recordset
With rsADOSetRecord
.Open "SELECT DISTINCT " & strFiledName & " FROM " & strTableName, adoDataGrid, , , adAsyncFetch
If Not .BOF Then
.MoveFirst
Do While Not .EOF
If .Fields(0).Value <> vbNull Then combo1.AddItem .Fields(0).Value
.MoveNext
Loop
End If
.Close
End With
End Sub