selecting between 2 fields in a query

N

norm

I have a table that has a list of Equipment (tblEquip)
I need to search from either on of 2 fields. But only one of the values
may be "known"- I may know the value of Equip or the value of RecvNum

How can I query these 2 fields, I have tried:
I would like to get away from using the * in the input box

WHERE (((tblEquip.E_EQUIP) Like [Vehicle or * For None]) AND
((tblEquip.RECV_NO) Like [Receiving or * For None]))
 
J

John Spencer

If that gives the required records you could also use

WHERE tblEquip.E_EQUIP Like Nz([Vehicle],"*"
AND tblEquip.RECV_NO Like Nz([Receiving],"*")

Otherwise life is a bit more complex

WHERE (tblEquip.E_EQUIP = [Vehicle] or [Vehicle] is Null)
AND (tblEquip.RECV_NO = [Receiving] or [Receiving] is Null)


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top