Returning a Value if Query Can't Find Anything

  • Thread starter Thread starter Tedd
  • Start date Start date
T

Tedd

I am trying to get a query to return a value(such as N/A
or 0) if the query can't find anything.

For example, if my table looks like this:

Employee Date
Xyz 2004-03-10

If I search for an employee that has a date that is less
than 2004-03-10 it will not find it. I would the query to
return something like "N/A" in the field insted of not
returning anything at all.

Do I need to use some kind of Union query for this?
 
I think this approach is flawed, because a query returns a
*recordset*, not a *value*. You might use DLookup in an
IIf statement.

stremployee = DLookup([Employee], _
<yourtablename>, [Date]< <datevalue>)

' DLookup will return Null if no match is found
stremployee = IIf(IsNull(stremployee),"No Value _
Returned",stremployee)

HTH
Kevin Sprinkel
 
Back
Top