Turning a filter off through VBA

branston

Registered User.
Local time
Today, 05:55
Joined
Apr 29, 2009
Messages
372
Hi,

Im sure im just missing something simple here...

Ive just created some code that opens a table and filters it:

strfilter = "[Number]= " & Me![Number]
DoCmd.OpenTable "TblMainList"
DoCmd.ApplyFilter , strfilter

but after some further actions I need the filter to be removed!
I have had a look but cant find anything that would do this. Surely it MUST be possible!!

Thank you
 
Have you tried

strfilter = ""
Docmd.ApplyFilter ,strfilter
 
Thanks for getting back to me.
Unfortunatley, that brings up an error: The ApplyFilter action required either the filter name or where condition is set. Which is silly, as i thought it was!! Im doing a test at the moment just putting the filter on, closing a message box and removing the filter. The code is below:

Dim strfilter As String
Dim strfiltoff As String

strfilter = "[Number]= " & Me![Number]
strfiltoff = ""

DoCmd.OpenTable "TblNumbersMain"
DoCmd.ApplyFilter , strfilter
MsgBox "ok"
DoCmd.ApplyFilter , strfiltoff

Am i making some silly mistake somewhere?
 
Ahha! I just remembered i had done this before somewhere... had a look through my notes and found it:

DoCmd.RunCommand acCmdRemoveFilterSort

Thanks anyway!
 

Users who are viewing this thread

Back
Top Bottom