- Joined
- Jul 30, 2012
- Messages
- 2
- Reaction score
- 0
Using Microsoft Access 2010
I can't seem to get the filter cleared either when closing or opening a form. I have the following code for a button that will do it, but it won't work on open or close.
Private Sub cmdRemoveFilters_Click()
If Me.Form.FilterOn Then
Me.Form.Filter = ""
Me.Form.FilterOn = False
End If
End Sub
In another button which I have labeled Search, I have the following, but it won't work all the time.
Private Sub CmdSearch_Click()
If Me.Form.FilterOn Then
Me.Form.Filter = ""
Me.Form.FilterOn = False
DoCmd.RunCommand acCmdFilterByForm
Else:
DoCmd.RunCommand acCmdFilterByForm
End If
End Sub
I have tried to put the first part of the code in the close event and in the open and current event, but it won't work. What am I doing wrong? Thanks.
I can't seem to get the filter cleared either when closing or opening a form. I have the following code for a button that will do it, but it won't work on open or close.
Private Sub cmdRemoveFilters_Click()
If Me.Form.FilterOn Then
Me.Form.Filter = ""
Me.Form.FilterOn = False
End If
End Sub
In another button which I have labeled Search, I have the following, but it won't work all the time.
Private Sub CmdSearch_Click()
If Me.Form.FilterOn Then
Me.Form.Filter = ""
Me.Form.FilterOn = False
DoCmd.RunCommand acCmdFilterByForm
Else:
DoCmd.RunCommand acCmdFilterByForm
End If
End Sub
I have tried to put the first part of the code in the close event and in the open and current event, but it won't work. What am I doing wrong? Thanks.