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

Dynamic combo box table selection based on another combo box input

Status
Not open for further replies.

BFP

Technical User
May 18, 2000
52
US
Hello.<br><br>I am looking for some VBA code that would dynamically show a table in one combo box based on the selection made in another combo box.&nbsp;&nbsp;For example, the first combo box would list major problem categories and the second one would list sub-categories based on the major one.&nbsp;&nbsp;Anyone done this yet?<br><br>Thanks,<br><br>--Dan
 
Create your first combo box as normal<br>Create the second one normally to<br>But after its done Click the &quot;Row Source&quot; then the 3 dotts button at the end<br>Then change the Criteria from blank to your 1st combo box on your form.<br>something like so:<br><br>SELECT DISTINCTROW MyTable.DisplayName, MyTable.ActualName FROM MyTable WHERE (((MyTable.DisplayName)=[Forms]![Form3]![Combo1])); <br><br>Then in your first combo boxes &quot;After update&quot; event put this:<br>combo2.requery 'Name of your second combo box<br> <p>DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.
 
Hi Doug.<br><br>I'm afraid I am confused on a couple of issues...<br><br>1) The only way I can click on the three dots (in 2000) is by having the &quot;Row Source Type&quot; set to &quot;Table/Query.&quot;&nbsp;&nbsp;Then, by clicking on the three dots, I can only select an existing table or query.<br><br>2) How will Access know which table to show?&nbsp;&nbsp;For example if my first combo box list (Table 1) has one column (say Groceries) and that field&nbsp;&nbsp;contains two items: Fruits and Vegetables.&nbsp;&nbsp;Now, I will have a table of Fruits and a Table of Vegetables.&nbsp;&nbsp;What underlying thing do I need to do in access to make your previous suggestion work?&nbsp;&nbsp;In other words, if I pick Fruits from my first combo box, how will access know to display Apples, Bananas, and Oranges in the second combo box?<br><br>Sorry, but I am hacking my way through this...<br><br>Thanks,<br><br>--Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top