Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form to act as a filter

Status
Not open for further replies.

westoby1989

Technical User
Jul 7, 2010
7
GB
I'm trying to develop a form for users to be able to filter through all customers entered into the database

I've written a query with every field of the customer table in. The idea is that in the filter form the user can enter as many criteria they want while leaving some fields blank. I tried the following formula in the criteria of the query:

IIf(IsNull([forms]![Customer filter]![Forenames]),([Customers].[Forenames]) Like "*",[forms]![Customer filter]![Forenames])

My theory behind this is that if the user enters anything in that particular field then it filters the results however if the field is left blank the criteria allows anything using the "*" wildcard symbol.

But it doesn't seem to work though. Any suggestions?
 
You wanted something like this ?
SELECT ...
FROM ...
WHERE Customers.Forenames & "" Like [forms]![Customer filter]![Forenames] & "*"

Or like this ?
SELECT ...
FROM ...
WHERE (Customers.Forenames = [forms]![Customer filter]![Forenames] OR [forms]![Customer filter]![Forenames] IS NULL)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top