My Form:
combo1 (ComboBox)
combo2 (ComboBox)
Database:
ID | Name
1 | one
2 | two
3 | three
4 | four
5 | five
6 | six
So,I want:
If Combo1.Text = "ID" Then
combo2 populate with
1
2
3
4
5
6
ElseIf Combo1.Text = "Name" Then
combo2 populate with
one
two
three
four
five
six
My Code:
How To Coding in:
'Code Here For Populate Combo2 (field ID)
'Code Here For Populate Combo2 (field Name)
combo1 (ComboBox)
combo2 (ComboBox)
Database:
ID | Name
1 | one
2 | two
3 | three
4 | four
5 | five
6 | six
So,I want:
If Combo1.Text = "ID" Then
combo2 populate with
1
2
3
4
5
6
ElseIf Combo1.Text = "Name" Then
combo2 populate with
one
two
three
four
five
six
My Code:
Code:
Dim RsClass As New ADODB.Recordset
Private Sub Form_Load()
conn 'connection from module
Combo1.AddItem "ID"
Combo1.AddItem "NAME"
End Sub
Private Sub Combo1_Change()
RsClass.LockType = adLockOptimistic
RsClass.CursorType = adOpenDynamic
If Combo1.Text = "ID" Then
RsClass.Open "select * from Class", conn, , , adCmdText 'Maybe This Line Wrong?
If Not RsClass.EOF Then
'Code Here For Populate Combo2 (field ID)
End If
ElseIf Combo1.Text = "Name" Then
RsClass.Open "select * from Class", conn, , , adCmdText 'Maybe This Line Wrong?
If Not RsClass.EOF Then
'Code Here For Populate Combo2 (field Name)
End If
End Sub
'Code Here For Populate Combo2 (field ID)
'Code Here For Populate Combo2 (field Name)