Clearing a Filter by Form

Posted on 2003-03-25
Medium Priority
Last Modified: 2008-02-01
Hello everyone, Heres my question!

I am using "DoCmd.RunCommand acCmdFilterByForm" to open a form in "Filter by Form" mode. This allows the user to create a custom filter to their liking. Once run, the user can then us a button I have created to push the "filtered" results to a generic report I have created. The problem I am having is more of an anoyance than anything. After filtering the records accroding to their needs. Another use may try to use this feature and find the criteria the last user entered on the "Filter by Form" screen. He/she can delete this criteria and eneter their own, but if they miss something it will fudge the reulting data.

I would like the "Filter by Form" to be cleared (no values in any field) when the user selects the button containing "DoCmd.RunCommand acCmdFilterByForm" . Can this be done and if so, anyone have any ideas?


Question by:syntnx
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 8205120
Just put this line before the filterbyform line:

Me.Filter = vbNullString

Author Comment

ID: 8205252
Didnt seem to work. Im not real familar with VB, is the following systax correct?

DoCmd.OpenForm "frmAgreementsFilter",acNormal, "", "",
acEdit, acNormal
Me.Filter = vbNullString
DoCmd.RunCommand acCmdFilterByForm

LVL 41

Accepted Solution

shanesuebsahakarn earned 500 total points
ID: 8206021
Try this:
DoCmd.OpenForm "frmAgreementsFilter"
DoCmd.RunCommand acCmdFilterByForm

You don't need all the extra parameters after the form name if you just want to pass the defaults.

You could also put this in the OnFilter event of the frmAgreementsFilter form instead:
Me.Filter = "" (as suggested by Wowbagger_TIP)
If you do this, then the filter is also cleared if the user decides to go back into Filter-By-Form later on.

Author Comment

ID: 8210781
You've done it again! Wowbagger_TIP I have posted some points for you too at http://www.experts-exchange.com/Databases/MS_Access/Q_20563840.html



Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question