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

Combo Box dependent selections 1

Status
Not open for further replies.

mrkshpntf

MIS
Apr 19, 2007
92
0
0
US


I have 2 combo boxes on a form each with its own list. I would like the second combo box to display a list depending on what is selected from the list in the first combo box.

There are two lists options to be selected in the second combo box, the names of these lists make the list of the first combo box

Please help.

Thanks in advance.
 
See faq faq702-4289 among many other posts on this forum. if you have questions after that, please ask.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
You can use either IF THEN or a SELECT CASE statement. It really depends on how many options you have. You can either list the values or use seperate SQL statments to query based on the option choosen. How are the combo boxes getting populated - queries or values?
 
traingamer,

Here is my situation in little more detail (with example)

The First combo box has simple list named Produce, which has two items Fruits and Vegetables only.

What I want to do when I select Fruits or Vegetables in the first combo box is that the second combo box displays a list of Fruits or list of Vegetables depending on what I selected in the first combo box.

For simplicity, I have created 3 tables: Produce, Fruits and Vegetables. These are basically 1 column lists with no need for a PK.

The link you have provided only has 2 tables. I worked on the code but have a problem with the "OR" part, if you catch my drift.

Thanks for your response and help.
 
In the AfterUpdate event procedure of the Produce combo:
Me![Fruits or Vegetables combo].RowSource = "SELECT yourField FROM " & Me![Produce combo]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya mrkshpntf . . .

In the [blue]AfterUpdate[/blue] of Combobox1, copy/paste the following (you substitute proper names in [purple]purple[/purple]):
Code:
[blue]   If Me.[purple][b][i]ComboboxName1[/i][/b][/purple] = "Fruits" Then
      Me.[purple][b][i]ComboboxName2[/i][/b][/purple].RowSource = "tblFruits"
   Else
      Me.[purple][b][i]ComboboxName2[/i][/b][/purple].RowSource = "tblVegetables"
   End If[/blue]
If you require sorting, make a query for each table and use those names instead.

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top