I've set up a command button to remove the filter that is applied to a form. I used the code from MS article Q208548 that is very simple: Me.Filter = ""
However, this does not actually clear the form's filter property (it does, however, display all the records as if the filter property were cleared!). When I check the property, I still see the previously applied filter! This is problematic because I generate a report that is based on the filter property of the form.
If I click on the command button a second time, only then is the form's filter property cleared.
How do I get the form's filter property to be cleared with one click of the command button? I've tried Me.refresh and Me.requery but neither help. Here is the full code (I put in the string declaration and message box so I could see what was in the filter property):
Private Sub cmdShowAllRecords_Click()
On Error GoTo Err_cmdShowAllRecords_Click
Dim stmsg As String
stmsg = Me.filter
MsgBox stmsg
Me.filter = ""
Me.refresh
stmsg = Me.filter
MsgBox stmsg
Exit_cmdShowAllRecords_Click:
Exit Sub
Err_cmdShowAllRecords_Click:
MsgBox Err.Description
Resume Exit_cmdShowAllRecords_Click
End Sub
Thanks for any help given!
RG
However, this does not actually clear the form's filter property (it does, however, display all the records as if the filter property were cleared!). When I check the property, I still see the previously applied filter! This is problematic because I generate a report that is based on the filter property of the form.
If I click on the command button a second time, only then is the form's filter property cleared.
How do I get the form's filter property to be cleared with one click of the command button? I've tried Me.refresh and Me.requery but neither help. Here is the full code (I put in the string declaration and message box so I could see what was in the filter property):
Private Sub cmdShowAllRecords_Click()
On Error GoTo Err_cmdShowAllRecords_Click
Dim stmsg As String
stmsg = Me.filter
MsgBox stmsg
Me.filter = ""
Me.refresh
stmsg = Me.filter
MsgBox stmsg
Exit_cmdShowAllRecords_Click:
Exit Sub
Err_cmdShowAllRecords_Click:
MsgBox Err.Description
Resume Exit_cmdShowAllRecords_Click
End Sub
Thanks for any help given!
RG