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

linking a combo box with a subform

Status
Not open for further replies.

trialerror

Programmer
Aug 18, 2003
15
US
Hi,
I have a main form with 2 combo boxes.The values in the combobox1 come from a query .Also the values in combo box 2 are limited by the selection made in combo box 1-(already finished this part).Next, I want to display in a subform (or some other way) all the other details of a table , depending on what is selected in combo box 2. For example if I select a city in combo box 1,the customrers of that city are displayed in combo box2.Now, if I select customer 1 in combo box2, I would like to view his details in a subform.(I have linked the 2 tables city-->customer as a 1 to many relationship).
Thanks in advance.
 
Does the main form have a recordsource at all?

I ask because subform child/master linking only works when you have a recordsource for the main form.

 
The main form does not have its recordsource.I created a blank form and placed the combo boxes on it which of course have their own record sources.
 
in which case you have two options.

1)
You have to reference the combo2 in the subforms RecordSource as a where clause.
Then, whenever the Combo2 value is changed you have to force the subform to requery itself.

2)
Create a table that basically has two fields. cbo1 and cbo2.
You then use this as the recordsource of your Main form and the subform linking will work.
One nice little benefit of this method is that the form will remember the last search performed, allowing a worker to close the database at lunch or end of day and the next time the database opens the user is brought straight to what they where last working on. With a bit of trickery (and another field in the new table to save UserID) you can even save this info seperately for each user.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top