• 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_Command97_Click:
    Exit Sub

Err_Command97_Click:
    MsgBox Err.Description
    Resume Exit_Command97_Click
   
End Sub
0
ssblue
Asked:
ssblue
  • 2
1 Solution
 
ArjiCommented:
This should clear your filter:

Me.Filter = ""
Me.FilterOn = True


0
 
ssblueAuthor Commented:
so do i create a new button and use your code to remove the filter?
0
 
ArjiCommented:
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
else
    DoCmd.ApplyFilter , "FilterField= FilterValue"   '<----If FilterValue is text then you would use "FilterField = 'FilterValue'"
    FilterApplied = True
end if





0

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