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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making a combo box selection show another item

Status
Not open for further replies.

jabarden

Technical User
Jun 16, 2003
19
US
Hi: When I select an item in a first combo box, is there a way to make it show a sub-menu in the form of a second combo box to the side.

For instance--Combo Box 1 has A, B, and C as it's values.
If A is selected, another combo box is made visible with the options of A.1, A.2, and A.3, where B and C are not visible
If B is selected, another combo box is made visible with the options of B.1, B.2, and B.3, where A and C are not visible

I think you get the point from here

For each item in the main combo box, I would like it to make it to make the related combo box visible. If they change the selection, make the previous selection hidden, and the new selection visible.

Thanks alot,

JABSNH
 
If the combo boxes are based upon queries, the sub-combo boxe's underlying query should have a filter condition based upon the first combo box. You will then add an event that refreshes the sub-combo-box query. I will be happy to provide an example if this is the case.
 
You might find my FAQ helpful: faq702-681

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
On the first comboboxes AfterUpdate event put:
Me![Secondcomboboxname].Visible = True
Me![Secondcomboboxname].SetFocus
Me![Secondcomboboxname].Dropdown

On the RowSource property of the first combobox put:
SELECT DISTINCT [letterfieldname] FROM tablename WHERE [letterfieldname] is not null;

On RowSource property of the second combobox put:
SELECT DISTINCT [numberfieldname] FROM tablename WHERE [numberfieldname Is Not Null And
[letterfieldname]=Screen.Activeform![letterfieldname];

Neil
 
DPATRICKCOLLINS:

Can you send an example of this?

Thanks
JABSNH
 
fneily: The Third part of what you said (Below) is coming up with a syntax error. I changed numberfieldname and tablename to the tables that I wanted them to point to, but it kept giving me a syntax.

On RowSource property of the second combobox put:
SELECT DISTINCT [numberfieldname] FROM tablename WHERE [numberfieldname Is Not Null And
[letterfieldname]=Screen.Activeform![letterfieldname];

 
Well SELECT DISTINCT [numberfieldname] FROM tablename WHERE [numberfieldname Is Not Null And
[letterfieldname]=Screen.Activeform![letterfieldname];

should be

SELECT DISTINCT [numberfieldname] FROM tablename WHERE [numberfieldname] Is Not Null And
[letterfieldname]=Screen.Activeform![letterfieldname];

 
ok, I was able to get the 2nd combo box to update with the 1st selection that was made in the 1st combo box. But if I change the selection in the first box, the second box doesn't change.

The way I got to where I am was creating a table each item in it (A, B, and C) in one column and details in the second column (1, 2, and 3). I made a query that that filtered by A, B, and C, and then set Combo Box 2's Row Source to that query.

The main question is, is there a way to refresh combo #2 whenever Combo #1 is changed?

Thanks Alot,
JABSNH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top