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

How can I filter a form using another form to do it? 2

Status
Not open for further replies.

jr4939

Technical User
Oct 4, 2002
8
US
I have one form consisting only of a combo box containing a list of countries and a Close command button. When the Close button is clicked, I want the records for another form (based on a query)to be filtered for the selected country. Can't figure out how to do this.
TIA for any help!
 
If the Close button of the 1st form launches the 2nd form, then use the Where Condition of the OpenForm method.

DoCmd.OpenForm formname[, view][, filtername][, wherecondition][, datamode][, windowmode][, openargs]

However, if the 2nd form is already opened, then on the OnClick event of the Close Button (or OnClose event of the form), set the Filter property of the 2nd form equal to the value of the combobox. You must also set the FilterOn property of the 2nd form to true.
 
Thanks very much for your quick and clear reply. But my coding skills are pretty rudimentary.

"...set the Filter property of the 2nd form equal to the value of the combobox..."

Have tried every code and macro variation I could think of to try to do this, without luck. What am I missing?

 
Here's an example. On the OnClick event of the close button on the 1st form, do this:

Private Sub cmdClose_Click()

Forms!form2.Filter = "lngIDorWhatever = " & cmbBox.Value
Forms!form2.FilterOn = True

DoCmd.Close


End Sub
 
Wow, now there's a helpful example! My solutions were way too complicated. - Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top