Query show blank if like...

Elmobram22

Registered User.
Local time
Today, 02:34
Joined
Jul 12, 2013
Messages
165
Sleep In: IIf(([Notes] Like "Sick*" Or "A/L*" Or "Half*"),IIf([Time Out]>=#21:55:00#,"Sleep In",""),"")

Hi All,

I have a column in a query and I want it to do the following...

If the notes column starts with the word sick, A/L or half then the sleep in column should be blank. If it does not run the rest of the query based on the time out.

The Like option I am putting in doesn't seem to be working as the records aren't affected currently.

Cheers,

Paul
 
You need to declare the entire comparison each time:

[Notes] Like "Sick*" OR [Notes] Like "A/L*" OR [NOTES] Like "Half*" ...
 
Sleep In: IIf(([Notes] Like "Sick*" Or [Notes] Like "A/L*" Or [Notes] Like "Half*"),IIf([Time Out]>=#21:55:00#,"Sleep In",""),"")

Changed it to this but still it doesn't seem to work. Think I'm missing something.
 
The Iif format is

Iif(criteria,true,false)

You haven't done that, your true for the Like is another Iif , look at your order.

Brian
 
Right I'm stuck then. I am changing the query from the prior one which said if Notes was blank then run the query but stop if it wasn't
 
It is not your Like it is the IIf


try

Code:
Sleep In: IIf(([Notes] Like "Sick*" Or [Notes] Like "A/L*" Or [Notes] Like "Half*"),"",IIf([Time Out]>=#21:55:00#,"Sleep In",""))

Brian
 
That's perfect. Knew I had something in the wrong place. Thanks for your help!
 

Users who are viewing this thread

Back
Top Bottom