5 pts.
 How to use lookup query to return only entries matching the related field of active record
I'm creating a lookup field and would like to list only those items relevant to the record actively using the lookup. So my DB has two tables one using the lookup which as a child ID field that I'd like to match with the parent ID field of another table.

Software/Hardware used:
ASKED: March 24, 2009  6:11 PM
UPDATED: March 29, 2009  4:11 PM

Answer Wiki:
This one shouldn't be that difficult. I'll assume you want to use 2 combo boxes, with the first selecting a category and the 2nd the lookup value. (You can't do this in 1 combo with multiple fields - at least not without some fancy VBA code). Ok, you have combo1 and combo2. Place them on a form In combo1 - set the Row Source value to the query from the first table: "Select fieldname from tablename, order by whatever" In combo2 - set the Row Source value to a new query that references the first, using this syntax: "Select lookupfieldname from lookupchildtable where lookupparentid = " & [forms]![yourformname]![combo1] create an afterupdate event for combo1. Choose code builder Your code should look like this Private Sub Combo1_AfterUpdate() me.combo2.requery End Sub That's it. Now, whenever you change a value in combo1, only the child values relating to that category will show in combo2.
Last Wiki Answer Submitted:  March 29, 2009  4:11 pm  by  Mraccess   60 pts.
All Answer Wiki Contributors:  Mraccess   60 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _