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!

How to populate 2nd combo box from 1st combo box?

Status
Not open for further replies.

trito

MIS
Jan 31, 2003
12
0
0
US
Hi all,

I'm trying to create 2 combo boxes that is used as a filter for a hotel inventory report. The first combo box is linked to a table with all our available destinations. I would like the 2nd combo box to show only hotels that are in the destination selected in the 1st combo box. I was thinking about creating a query based off the selecttion on the 1st combo box but I don't know how to do this. If anyone can help me with this I would really appreciate it.

Here are the 2 tables I have:

Destination_Table
Destination (FIELD)

Hotel_Name_Table
HotelName (FIELD)
Destination (FIELD)

Thanks in advance,

Tri
 
You are on the right track.
Let's say that your form is called Form1, and 1st combo box is Combo1. When you create the query in the query designer, just write in the Criteria (for the field that is going to be the displayed in the 2nd combo box) Form1!Combo1.value. Then save the query and use it as record source for 2nd combo box.
This should do it.
:)
 
Try this:
Step 1)
Create a query using Hotel_Name_Table
HotelName (FIELD)
Destination (FIELD)
Put this in the criteria for Hotel:
[Forms]![FORM1]![Destination]

**Destination represents the Name of the combo box for your Destination choices in your form**

Save the query (for this example I will call it TEST1)

Step 2)
In the Form (For this example call it FORM1)
HotelName Combo Box Properties:
Name: Hotel
Control Source: HotelName
Row Source Type: Table/Query
Row Source: TEST1

Step 3)
Macro:
Name: Run Hotel Query
Action: Requery
Control Name: Hotel

Step 4)
FORM1 at the Destination combo box at the after update event, click on Run Hotel Query

This should populate your hotel choices according to whatever desination is picked.

Hope this helps.

PBrown
 
Simco & PBrown,

Thanks for your suggestions, I for it working fine. Just for anyone else who might be doing this you have to have Multiselect OFF on the 1st combo box or it won't pull the value from it.

Thanks again guys,

Tri
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top