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!

Filter by form or query? 1

Status
Not open for further replies.

jlnewbie

Technical User
Aug 9, 2000
69
I want a form to open and display only those items related to my selection on another forms combo box.
My relationship is one site to many buildings. So if I select site 1, form 2 will display the many buildings associated with it.
This is easily done via query where I set the criteria and save that query. But I've seen forms do this via filter or filter by form or macro (apply filter). How is that done? Which is easier? Thank You




JLopez
Lopez31@ATC-Enviro.com
Environmental Services @ Your Service
 
How about....

Dim strFilter as String
strFilter = "Site = '" & me.YourComboBox & "'"
DoCmd.OpenForm "YourFormName",,,strFilter

If the combo box value is numeric, replace the strFilter line with...
strFilter = "Site = " & me.YourComboBox


Randy
 
Take a look at the 4th parameter of the DoCmd.OpenForm method.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thank You Randy, I understand the code but where do I place this code. On the combo box or in form 2




JLopez
Lopez31@ATC-Enviro.com
Environmental Services @ Your Service
 
Place the code in the click event of the button that opens the second form.


Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top