IIf

C

clueless

Hi,
I am trying to put an IIf statement together. What I need it to basically
do is if a carrier arrives before 13:00 (1 pm), it's early. If it arrives
after 16:00 (4 pm), it's late, between 13:00 (1 pm) and 16:00 (4 pm) it is on
time. It does not error in design view but when I go to datasheet view, the
column reads Error. I would appreciate any help, not sure what I am doing
wrong. Thanks!

Expr1: IIf([SealNumber]="LTL" Or "LCL" And [ArrivalTime] Between "04:00" And
"12:59","early",IIf([SealNumber]="LTL" Or "LCL" And [ArrivalTime] Between
"16:01" And "03:59","Late","OnTime"))
 
J

John Spencer

You might try the following.

Expr1: IIf([SealNumber] IN ("LTL","LCL") And [ArrivalTime] Between
#04:00:00# And #12:59:59#,"early"
,IIf([SealNumber] In ("LTL", "LCL")
And ([ArrivalTime] Between #16:01:00# And #23:59:59#
OR ArrivalTime Between #00:00:00# and #03:59:00#),"Late","OnTime"))

Times and Dates are delimited by # markers not quotes.

You must repeat both sides of a comparison. So You can use the In
statement or you can use

(SealNumber = "LTL" or SealNumber = "LCL") AND ArrivalTime ...

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
C

clueless

Hi John,

Perfect!!!!! Thank you so much for your help.
--
clueless


John Spencer said:
You might try the following.

Expr1: IIf([SealNumber] IN ("LTL","LCL") And [ArrivalTime] Between
#04:00:00# And #12:59:59#,"early"
,IIf([SealNumber] In ("LTL", "LCL")
And ([ArrivalTime] Between #16:01:00# And #23:59:59#
OR ArrivalTime Between #00:00:00# and #03:59:00#),"Late","OnTime"))

Times and Dates are delimited by # markers not quotes.

You must repeat both sides of a comparison. So You can use the In
statement or you can use

(SealNumber = "LTL" or SealNumber = "LCL") AND ArrivalTime ...

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================

Hi,
I am trying to put an IIf statement together. What I need it to basically
do is if a carrier arrives before 13:00 (1 pm), it's early. If it arrives
after 16:00 (4 pm), it's late, between 13:00 (1 pm) and 16:00 (4 pm) it is on
time. It does not error in design view but when I go to datasheet view, the
column reads Error. I would appreciate any help, not sure what I am doing
wrong. Thanks!

Expr1: IIf([SealNumber]="LTL" Or "LCL" And [ArrivalTime] Between "04:00" And
"12:59","early",IIf([SealNumber]="LTL" Or "LCL" And [ArrivalTime] Between
"16:01" And "03:59","Late","OnTime"))
 

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

Similar Threads

IIf statement 3
Help with IIf statement 2
Extracting just the time portion 6
Need some PWA help 0
INDEX MATCH SMALL 13
Countifs with different restrictions 1
HELP! What's Up With Time 2
Expressions in a form 2

Top