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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF() in query criterion

Status
Not open for further replies.

fredzeppelin

Technical User
Mar 17, 2005
26
0
0
US
I'm trying to create a query criterion that
does one of two things:

1. If some abitrary field condition elsewhere is true, query on this:
Code:
Like "*" & [Serial Number?] "*"
a 'wildcard' search base on the Serial Number or fragment entered in the parameter box.

2. If the the arbitrary condition is false, the criterion should return nothing.
This criterion is to be OR'd with others to create a query with multiple purposes.

Code:
IIF('condition', "Like '*' & [S/N?] & '*' ", "")


This seems like it oughta work, and I found the single/double quote convention in the doc's somewhere, don't remember where.

On the false condition, the qry returns nothing(as desired). On the true condition, the parameter box fires, but the qry returns nothing.

Any ideas/comments?

I know that I can create separate queries, and that's my current workaround, but it seems less than elegant.


thanks ....brad
 
SELECT ...
FROM ...
WHERE ...
(condition And [yourField] Like '*' & [S/N?] & '*') ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top