why doesn't clear filter work?

rgsmpx

New member
Local time
Today, 20:50
Joined
Oct 8, 2001
Messages
6
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
 
Thanks, I just tried FilterOn = false and it works. The command button now clears the filter.

But strangely, when I then do a sort of the records by clicking on "Sort A-Z" on the toolbar, the previous filter reappears in the form's filter property. How do I prevent that? It's a problem if a user were to show all records, then sort them in a different order, and then find that the report he prints out is wrong because it has the previous filter still applied.

Thanks again.
RG
 

Users who are viewing this thread

Back
Top Bottom