What is the Opposite of Filter Event?

  • Thread starter Thread starter Lulu
  • Start date Start date
L

Lulu

I know I can tie an action to the OnFilter event, but what
is the name of the OPPOSITE action -- that is when the
filter is removed? I have a counter that shows a value on
the Filter event. I want to reset the counter when the
filter is removed, i.e., when the action is
Docmd.ShowallRecords. But what event do I tie it to?

Thanks for any insight.
 
The ApplyFilter event occurs when the filter is put in place and when the
filter is removed.

However, before getting into that, why can't you use the code that is
running the DoCmd.ShowAllRecords step to reset the counter?
 
I wasn't using an event to run the Docmd.ShowAllRecords.
I was allowing the user to use the Filter ToolBar. But I
suppose I can use a button labeled Clear Filter which only
appears when the form has been filtered and disappears
when the filter is removed.

But thanks for the insight on ApplyFilter. Did not
realize is also meant De-Apply Filter.

Now I'm pondering a new dilemma -- Removing the Filter
does not CLEAR the filter criteria. That is, the next
time the user enables Filter by Form, the previous value
is still present. Looking for a way to wipe the criteria
clean when the filter is removed.
 
The Filter string retains the most recently used filter. That is how ACCESS
is designed. Even if you were to close the form and then reopen it, that
string would still be there. You need to set the .Filter property to an
empty string when you want to "delete" it.

Sounds as if you should look at removing the ability for your users to use
built-in filter menus and program your own. That will give you the ability
to control all the things you are struggling to handle.
 
You can use a select case to sort out which type of event ApplyFilter is
through its ApplyType parameter

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
'MsgBox ApplyType & ";" & Me.Filter 'Use this to play around and get a feel
for the ApplyType constants
Select Case ApplyType
Case acApplyFilter '=1 -- typical case of applying a filter

Case acShowAllRecords ' = 0 -- filter is removed
Me.Filter = "" 'clear the previously stored Filter
Case acApplyServerFilter ' = 3 ?

Case acCloseFilterWindow ' = 2 ?

Case acCloseServerFilterWindow ' = 4 ?

End Select

End Sub

HTH,

Kevin
 
Back
Top