VB COde for invoking Filter By Form from Button

Posted on 2008-02-08
Medium Priority
Last Modified: 2013-12-26
I have a simple form with a number of fields. I want to add a button on the form so that it wil invoke the Filter By Form function. Or is there an easier way to build search forms? I don't mind allowing the user to search for all items on the form.
Question by:jcaiola
LVL 14

Expert Comment

ID: 20850075
once you have the filter built...
me.filter = "MyField = 'MyValue'"

Author Comment

ID: 20850218
I have a form called "Home"
On this form are four fields: "Name", "Number", "City", "Zip"
I want to click a button on that form and have it bring back the same 'form', but as a search form with all of the fields blank.
LVL 28

Accepted Solution

TextReport earned 400 total points
ID: 20850622
To have a command button invoke the filter by for you use

DoCmd.RunCommand acCmdFilterByForm

Cheers, Andrew
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.


Author Comment

ID: 20850714
Thanks - this should do the trick.

One final question. If I want to use a command button to jump to a form with a subset of the larger form's fields, search and then come back to the original form with the found record selected, do I just do this by creating a small form, opening it as a popup, searching for the appropriate record, and then closing it?
LVL 28

Expert Comment

ID: 20850776
That is a major piece of VBA coding and you are on the right lines with the logic.
Cheers, Andrew
LVL 75
ID: 20852063
"I want to add a button on the form"
Why not user the built in right click menus ... OR .. easily build your own professional looking menus/toolbars.

Everything you need is here ... see this link:

Not sure it that article mentions it, but ... when you are in the Customize mode (dialog) ... if you hold down the Control key, you can drop and drag (ie, copy) menu items from one place to another ... handy for making a new menu that is similar another one.

Here is a related link also:



Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

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

Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

607 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