I presume your query references the fields in the 1st form.
Don't open the query. Create a form based on the query and use the button to open the new form. The downside is that if keeping it that simple, the form will open regardless of whether or not the search form fields have data in them. Opening the form from the nav pane will also run the query. If you're OK with those quirks, then it should be that simple. If not, you'll need to tweak the approach.
- "doesn't work" doesn't help. Implement changes in copies of your database.
I’m telling everyone it's good to eat dried grapes. It’s all about raisin awareness.
Create a form bound to the query, and open it from the button instead of the query.
Great It works great .. I'll put some code for 0 records in the on-open event to cancel sub if it has no data .. thank you both.
Basically, you are filtering your data.
Design a form, using the query as the form record source. Remove the criteria in the query.
Add the fields from the query to the form detail section. Set the form default view to Continuous Forms
In the form header, add the unbound combo box for the territory. (cboTerr)
Add a button in the header. The click event of the button would have code
Button name -> "btnFilter"
Caption -> "Filter"
Add another button to remove filterCode:Private Sub btnFilter_Click() Me.Filter = "Territory = '" & Me.cboTerr & "'" Me.FilterOn = True End Sub
Button name -> "btnNoFilter"
Caption -> "Remove Filter"
Code:Private Sub btnNoFilter_Click() Me.Filter = vbNullString Me.FilterOn = False End Sub
I don't know if cboTerr is a number or text. If cboTerr returns a number, change
toCode:Me.Filter = "Territory = '" & Me.cboTerr & "'"
Code:Me.Filter = "Territory = " & Me.cboTerr
Drat! Late again...![]()
HTH
-----
Steve
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)