Hi,
I have multiple combo boxes on a form. Depending on what a user selects in one combo box, I’d like the next combo box to populate with certain values. Eg, when a user selects a certain city/state, I would like another combo box to be populated with ‘clients’ that only exists in that city or state. Here is some sample code that I have:
Set ThisDB = CurrentDb
StateText = Me.State
SQLString = “SELECT tblClient.Surname, tblClient.FirstName, tblClient.State” & _
” FROM tblClient INNER JOIN tblState ON tblClient.State = tblState.StateID” & _
” WHERE tblState.StateID =” + StateText + “;”
Set ClientRecords = ThisDB.OpenRecordset(SQLString)
ClientRecords.MoveLast
ClientCount = ClientRecords.RecordCount
ClientRecords.MoveFirst
If ClientCount = 0 Then
MsgBox “There are no clients listed under that state”
Exit Sub
End If
Do Until ClientRecords.EOF
Me.ctrlClient.AddItem ‘???
Loop
As you can see, I can look up the list of users based on what state the user has selected. I’d then like to add the clients surname and first name to one row in the ‘ctrlClient’ combo box, looping through all clients until it is populated. I can add an item, but I assume this adds one particular field to one column in the combo box – how do I go about adding other fields to other columns?
Cheers,
Jason