Aiysha
asked on
Getting value in a combobox based another combo.
How can I populate the combo2 from the value in combo1 both of these values are obtained from database. The following code is suppsed to do it however the program doesnt read this code when I change the selection in combo1
Private Sub CmbState_Change() <---Is this the right function name?
Dim conn
Dim rec
Dim myvalue
myvalue = Me.CmbState.Text
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OL EDB.4.0;Da ta Source=C:\Database.mdb;Per sist Security Info=False"
esql = "select BAT from Dataset where STATE = " & myvalue & ";"
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
If rec.RecordCount > 0 Then
rec.MoveFirst
Do Until rec.EOF
FacilitySelection.CmbBat.A ddItem rec("STATE")
rec.MoveNext
Loop
End If
conn.Close
Set conn = Nothing
End Sub
Private Sub CmbState_Change() <---Is this the right function name?
Dim conn
Dim rec
Dim myvalue
myvalue = Me.CmbState.Text
Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OL
esql = "select BAT from Dataset where STATE = " & myvalue & ";"
rec.Open (esql), conn, adOpenStatic, adLockReadOnly
If rec.RecordCount > 0 Then
rec.MoveFirst
Do Until rec.EOF
FacilitySelection.CmbBat.A
rec.MoveNext
Loop
End If
conn.Close
Set conn = Nothing
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.