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

Need to create AfterUpdate Code

Status
Not open for further replies.

rl78

MIS
Sep 26, 2002
17
US
Hello,
I have linked 2 SQL tables into my access database for the purpose of having combo boxes pull up this data. Lets assume, combobox1 looks up table1 data and combobox2 looks up table2's data. Here is where Im stuck::: when the user clicks on combobox1 and selects from the drop down list, the values that correspond to that foreign key in combobox2's data should only show up. Instead, I get all of table2's data. I know I need to create code in and AfterUpdate procedure, but I have no clue as to where to begin. Any suggestions?
 
rl78,

It's always best for flexibility to use queries as the basis for your forms, reports, and combo boxes. Combobox2 will only give you specific choices if you base it on somehting other than just a table (like a query). Your combobox2 recordsource query should have its primary key criteria based on the value of combobox1 (such as Forms![YourFormName]![Combobox1]). That way, you don't need to run a procedure on the AfterUpdate event. This way, Combobox2 will have only records where the primary key value matches the selected row in combobox1.

Hope that helps.
 
rl78,

One more thing. The AfterUpdate event of combobox1 should cause a Requery of combobox2. That can be done by a macro or code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top