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

Ms Access VBA Code - Apply and remove a filter

I have a form with a combo box where the user selects a value from the list.
I then have a query that uses this value as the imput to a filter
Next on the After update of the combo box I set the filter using the code
   DoCmd.ApplyFilter "Q-300-03QFServiceCo"

What VBA Code can I use to remove the filter and return to the all records view?
What event should I use to to remove this filter? Add a button "Remover Filter"
Is there a more efficient method to set this filter from VBA code without using the Query and remove it when desired?.

Thanks all for your assistance

Lou Dufresne
Lou Dufresne
2 Solutions
docmd.showallrecords reverses the filter.

The technique of preference is up to you and your users.  A button is fine.  I prefer adding a "dummy" entry in the combo box like "<none>"  that removes the filter.   You can also just rely on the Access menus and buttons for removing filters.

Rather than filters, a more common technique is to reference the combobox in criteria of a query that limits the dataset you are working with.  
Rey Obrero (Capricorn1)Commented:
private sub cmdClearFilter_click()
end sub

to set the filter in the afterupdate event of the combo

private sub combo1_afterupdate()
me.filter="[fieldName]='" & me.combo1 &"'"
end if
Lou DufresneIT Business Analyst CSM / Project ManagerAuthor Commented:
Thanks Both of you
I appreciate you suggestions

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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