We help IT Professionals succeed at work.
Get Started

Access Code - Filter grid based on contents of search field

Last Modified: 2012-06-21
Helllo, I have what I think is a simple question.

I have a "customer grid" form (simple summary continuous form that shows a record for every customer in our databse).  The list of customers has gotten very long, so I want to put a single filter field int he header of the form.  

* Lets call this search/filter field "FilterInput", and say it is unbound.
* Lets say there's a field for each customer called ContactShortName (short name of the client)

I just want an AfterUpdate event that does a LIKE or CONTAINS filter based on what is typed into the search/filter box.  For example, if a user types "Micro" into FilterInput, it would filter the list of clients in the form to just clients who's ContactShortName CONTAINS the text "Micro".  So "Microsoft Inc" would show, as would "Advanced Micron", etc.

Has to be easy right?  I've used variations of the code I inserted below to no avail--get error messages including type mismatch, etc.  Can someone help?

Follow-up question: After properly setting the filter, do I do a DoCmd.ApplyFilter to apply it?  Or FilterOn = True?  Thanks.
Me.Filter = ("frmCustomersGrid") And (Contacts.ContactShortName) Like "*" & Me.FilterInput & "*"
Me.FilterOn = True

Open in new window

Watch Question
Most Valuable Expert 2012
Top Expert 2013
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE