Help with conditions

wglmb

Registered User.
Local time
Today, 22:37
Joined
May 7, 2005
Messages
21
I currently have a query which takes its criteria from a form called search. This all works fine, unless the user leaves a field in the search form blank. Then the query has no results.
What I'd like is for a blank field to act as a wildcard.
I guess the reason this doesn't automatically work is that Access (effectively) puts " & " around the criteria taken from a form, so the criteria ends up as " " not (there's a space there!).

I tried entering a criteria in the query that says:
IIF([Forms]![Search]![Date] Is Null,*, [Forms]![Search]![Date]
this doesn't work. For one thing Access edits the * into "*", so it is no longer a wildcard. Secondly, I've never used IIF before, so it's probably wrong anyway...

So, can anyone help me do this?
Even if a blank field cannot be used as a wildcard, any character would do...
 
For starters, the way to use the null test in a iif() is:

iif(isNull(fieldtotest), true part, false part)

Hope this helps.
 
Duh! Duh! Duh! Sorry, the answer was shouting me in the face. What I was trying to achieve with this query is exactly what is achieved by a filter...sorry!
 

Users who are viewing this thread

Back
Top Bottom