change combo box available selection?

H

HotRod

I have two combo boxes on a form that are both linked to the same table
"location" that contains on column 1 all of the main locations and in column
2 all of the sub locations for each main location. I want the user to select
the Main Location from combo 1 and then only be shown the sub locations in
combo 2 that match the Main Location in combo 1.
 
W

Wolfgang Kais

HotRod said:
I have two combo boxes on a form that are both linked to the same
table "location" that contains on column 1 all of the main locations and
in column 2 all of the sub locations for each main location. I want the
user to select the Main Location from combo 1 and then only be
shown the sub locations in combo 2 that match the Main Location
in combo 1.

Create 2 queries.
Query 1 selects all main locations (you might have to use the unique
values property to show each main loaction only once). Use this
query for combo 1.
Query 2 selects all sub locations were the main location is the one
displayed in combo 1. You can use the epression builder to point
to combo 1 on the form. Use query 2 for combo 2.
Then, create an event procedure for the AfterUpdate event of
combo 1 that executes
combo2.Requery
 
M

MBSNewbie

I just learned something!
OK, here goes Create your two combo Boxes
In the properties window try this:

Row/Source Type = Table/Query

Row Source for Combo1:
SELECT DISTINCT Location.Main FROM Location ORDER BY [Main];

Row Source for Combo2:
SELECT DISTINCT Location.Sub, FROM Location WHERE (((Location.Main)=[Forms]![Form1]![Combo1]));

Location = Change to Table Name where the info resides.
Main - Change to Field Name for Main
Sub - Change to Field Name for Sub
Form1 - Change to Name of Current Form
Combo1 - Change to Name of first combo box

Hope it works, give it a go!
Tammie
 
H

HotRod

Interesting approach. I'll give it a go THANKS


I just learned something!
OK, here goes Create your two combo Boxes
In the properties window try this:

Row/Source Type = Table/Query

Row Source for Combo1:
SELECT DISTINCT Location.Main FROM Location ORDER BY [Main];

Row Source for Combo2:
SELECT DISTINCT Location.Sub, FROM Location WHERE (((Location.Main)=[Forms]![Form1]![Combo1]));

Location = Change to Table Name where the info resides.
Main - Change to Field Name for Main
Sub - Change to Field Name for Sub
Form1 - Change to Name of Current Form
Combo1 - Change to Name of first combo box

Hope it works, give it a go!
Tammie
 

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

Top