Clear Filter on closing a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Waht is the VBA for every closing the form, the filter will atuotomatically
removed, because often that it will remember the filter and the clerck said "
I can not see my data that I just entered" they he/she did not remove the
filter.

On the form property I would write the VBA on close event.

Thanks in advance,

Frank
 
Try:

Private Sub Form_Close()

Me.FilterOn = False
Me.Filter = vbNullString

End Sub
 
Doug,
I have put your code, but it does not work. I tried to open my form than I
put cursor in the amount field, and typed >1000000, then I filter by form, it
worked, it showed only amount bigger than 1 million, than I closed the form,
and I open it again, and I see the one that I typed in the amount field
1000000 still showed.

I appreciate your idea again.

Thanks

Frank
 
You sure the code is actually firing? Put a breakpoint in there to make sure
it is.
 
I have the same problem. I tried the code suggested and it didn't work either.
I have tried all sorts of code including:
Private Sub cmdRemoveFilters_Click()
If Me.Form.FilterOn Then
Me.Form.Filter = ""
Me.Form.FilterOn = False
End If
End Sub

I can't get the filter to clear. If I click on the button with the above code, which will permit me to filter by form again without anything in the field which I had put the previous selection criteria, but when I close the form, open it again, the same field in which I had the original search criteria still contains the search criteria. The only thing that works it to first click on the button with the above code, then filter by form.
But why won't it clear the filter on close (or open or load or whatever)?
 
I just fournd this. It seems to work. I say that will a little intrepedation but I tried ti several times and it seemed to clear the filter. It is not my code, and I don't take responsibilty for it.
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Form_Open_Err

Me.Filter = ""
Me.FilterOn = False

Form_Open_Exit:
Exit Sub

Form_Open_Err:
MsgBox Err.Number & " - " & Err.Description
Resume Form_Open_Exit

End Sub
 
Back
Top