Combo Box - how do you populate/filter it using another Combo Box Selection

K

King Kaos

I've seen the examples but I can not get this to work - what is the simple
code for have a selection from a first combo box make the selection for a
second combo box. Example. I have a table that list drugs and their
categories like antidepressent - zoloft, antianxiety - xanax etc. When I
select Antidepressant from the first combo box I want it to bring up all the
medication in the second combo box? I'm a newbie at this - Anyone who is
there, thanks for the help
 
B

Bob

I generally do this with two tables. One table would be
the categories themselves and the other table would be the
specific medications with an ID in each record to tie it
to the category.

In the first combo box you query the Category table to
list each category. The second combo box queries the
Medications table but in the criteria area of the query
for the CategoryID you specify that you want to use the
value in the first combo box.

Something like:

=Forms![MyForm]![MyFirstComboBox]

I use the OnGotFocus event to requery the second combo box.

Something like:

Private Sub SecondComboBox_GotFocus()
DoCmd.Requery "SecondComboBox"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top