Link to home
Start Free TrialLog in
Avatar of smoore6809
smoore6809

asked on

How Do I fill a combobox based on results of another combobox in vb6?

I usually program in microsoft access and use the after update of the first combobox to populate the second. How can I do this in VB6 when there is no "afterUpdate?

Avatar of Cem Türk
Cem Türk
Flag of Türkiye image

you need to update second combobox in the onchange event of the first combobox
Avatar of smoore6809
smoore6809

ASKER

I can't get the onchange to fire.
Private Sub cboCategory_Change()
strSQL = "Select strlookup " _
    & "     from tblLookups " _
    & "    Where strCategory='" & Me.cboCategory & "'" _
    & " order by strlookup asc;"

rs.Open strSQL, cnn

With rs
    Do While Not .EOF
    CboLookup.AddItem rs!strlookup
    rs.MoveNext
    Loop
    .Close
    Set rs = Nothing
End With

End Sub

Private Sub Form_Load()
Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset

cnn.Open pstrConnectionString

strSQL = "Select distinct strCategory " _
    & "     from tblLookups " _
    & " order by strCategory asc;"

rs.Open strSQL, cnn

With rs
    Do While Not .EOF
    cboCategory.AddItem rs!strCategory
    rs.MoveNext
    Loop
    .Close
    Set rs = Nothing
End With
   
   
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Cem Türk
Cem Türk
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't know what that means...sorry