[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Whats New!
Need a database?
Tips via email
Learn VBA
Questions Answered
Access Tips Index
What is MS Access


Using a Combo Box to Filter Another Combo Box

This tip will show you how to filter the values that can be selected in a second Combo Box, depending on the value of the first Combo Box.

Set up your two combo boxes. Make sure you choose a field in both combo boxes that will be used to link and filter each of the combo boxes. As an example, if using the departments and units of a hospital, choose DepartmentID for both combo boxes. DepartmentID would most likely be the Primary Key (but not always) in the first combo box. In the second Combo box it would be the Foreign key.

You can hide DepartmentID in the second Combo Box if you wish.

Open the properties for the first combo box and under the 'other' tab take a note of the 'name' of the Combo Box, you will be using this later.

Open the properties for the second combo box. Next to the 'Row Source' property, click on the '...'.

This opens the query related to the combo box.

In the criteria row under the category field, type the following:

[Forms]![Form1]![Combo1]

Where Form1 is the name of the form containing the combo boxes.

And, Combo1 is the name of the first combo box you have just made.

Change these names to suit your own database.

Close and save the query.

Open the properties for the first combo box under the 'event' tab next to 'After Update'. Click the '...' button and select Macro.

OK

In the Action column, select the 'Requery' and, down the bottom in the box next to 'Control Name', type:

Combo2

Where Combo2 is the name of your subcategory combo box (the combo box you wish to filter).

Once again change Combo2 to the name of your combo box.

Close and save the Macro.

(This will rerun the query each time the value changes in the first combo box.)

Try it out.

 

Do you like this tip? Subscribe to my weekly Newsletter to receive tips weekly via email. Click Here to subscribe.

footer for Microsoft Access page