epuglise
asked on
When/how to clear a filter
I have two forms:
1. A search Input form (with a search button that starts my code)
2. A results form that consists of a master form that has some "function" buttons and a subform within which the results are displayed in a datasheet
When the user clicks Search, the code examines all of the possible parameters and creates the "where" clause for the ResultsSub form; however, I can't get it to forget the filter once the ResultsMain/Sub form closes. So if the user clicks the "back to search" or "main menu" button on the ResultsMain, it doesn't drop the filter. I currently have a command in the ResultsSub form at the "on close" event to set the filter to nothing:
me.filter = ""
but it isn't working.
When / where should i put the me.filter = "" command?
thanks
1. A search Input form (with a search button that starts my code)
2. A results form that consists of a master form that has some "function" buttons and a subform within which the results are displayed in a datasheet
When the user clicks Search, the code examines all of the possible parameters and creates the "where" clause for the ResultsSub form; however, I can't get it to forget the filter once the ResultsMain/Sub form closes. So if the user clicks the "back to search" or "main menu" button on the ResultsMain, it doesn't drop the filter. I currently have a command in the ResultsSub form at the "on close" event to set the filter to nothing:
me.filter = ""
but it isn't working.
When / where should i put the me.filter = "" command?
thanks
You mention: When the user clicks Search, the code examines all of the possible parameters and creates the "where" clause for the ResultsSub form
Does this actually modify the "WHERE" clause of the SQL string that is the Recordsource for the subform, or does it modify the Filter property of the subform? If it modifies the WHERE clause, setting the "Filter" property to "" will not do anything for you.
Does this actually modify the "WHERE" clause of the SQL string that is the Recordsource for the subform, or does it modify the Filter property of the subform? If it modifies the WHERE clause, setting the "Filter" property to "" will not do anything for you.
ASKER
@DBMX: can I set that form filter property if that form is not open? Because that form won't be open when the call is made.
@ fyed: I pass the where clause via open args and the clause ends up in the Filter property of the form.
thanks all!
@ fyed: I pass the where clause via open args and the clause ends up in the Filter property of the form.
thanks all!
ASKER
so to clarify the forms:
I have a Search form
I have a Results form.
they're two different forms. the Results form consists of a Master and Sub form.
I have a Search form
I have a Results form.
they're two different forms. the Results form consists of a Master and Sub form.
"can I set that form filter property if that form is not open? "
I'm afraid not. Form needs to be open.
"I pass the where clause via open args and the clause ends up in the Filter property of the form."
You really just need to pass either a Filter string OR a WHERE clause ... like so:
DoCmd.OpenForm "YourFormName",acFormDS ,, <WHERE CLAUSE HERE>
The WHERE Clause will do the filtering ...
mx
I'm afraid not. Form needs to be open.
"I pass the where clause via open args and the clause ends up in the Filter property of the form."
You really just need to pass either a Filter string OR a WHERE clause ... like so:
DoCmd.OpenForm "YourFormName",acFormDS ,, <WHERE CLAUSE HERE>
The WHERE Clause will do the filtering ...
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!!!
Me.YourSubFormControlName.
Me.YourSubFormControlName.
' other search code ...
' set new filter.
mx