• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 409
  • Last Modified:

remove filter

i used the "command button wizard" to build the following - it applies a filter based on the selection.  this button is on my form "ReadFrm"

i need to be able to remove the filter as well.  I  would like to be able to apply the filter with the first click and then remove the filter with the second click???????? or at least add a second button to remove the filter. (nothing in the "command button wizard" on removing the filter????

Private Sub Command97_Click()
On Error GoTo Err_Command97_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70

    Exit Sub

    MsgBox Err.Description
    Resume Exit_Command97_Click
End Sub
  • 2
1 Solution
This should clear your filter:

Me.Filter = ""
Me.FilterOn = True

ssblueAuthor Commented:
so do i create a new button and use your code to remove the filter?
Do do this with one button you would have to set up a Public variable in a module:
Public FilterApplied as Integer

In the On Open event of your form, clear the variable:
FilterApplied = false

Now in the On Click of your button:

If FilterApplied then
    Me.Filter = ""
    Me.FilterOn = True
    FilterApplied = False
    DoCmd.ApplyFilter , "FilterField= FilterValue"   '<----If FilterValue is text then you would use "FilterField = 'FilterValue'"
    FilterApplied = True
end if


Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now