Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronized combo boxes

Status
Not open for further replies.

IITRIccd

Technical User
Sep 21, 2001
3
US
I am trying to create a form with two combo boxes. I would like to select a category in the first box and then have the second box display only the items in that category. Do I need the information to come from one query? Please give an example.

thank you
 
Private Sub Combo1_AfterUpdate()
Combo2.Rowsource = "SELECT LNAME FROM MYTABLE WHERE SEX = '" & Combo1 & "'"
End Sub

In the above example...
Combo1 has sex M and F.
Which ever sex you choose will show in Combo1.
Combo2 now has all the last names of each person from our table that for this sex.

ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
thanks for your help. I'm having some trouble getting it to work. I have put the code from your example into the event for AfterUpdate of the 1st combo box. But, I get an error message about the select statement when I click on the 2nd box. This is what mine looks like, please let me know whats wrong.

Private Sub Combo1_AfterUpdate()
Combo2.RowSource = "Select [LastName] = '" & Combo1 & "'"
End Sub

thanks
 
You are missing the FROM portion and the WHERE statement of your SQL statement.

Combo2.RowSource = "Select [LastName] From TableName Where [FirstName] = '" & Combo1 & "'"

I am assuming that Combo1 is FirstName.
ljprodev@yahoo.com
ProDev, MS Access Applications B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top