IIf statement using a time field

G

Guest

I have a form with [Start_Time] and [Stop_Time] and a {Shift] field that has
two choices, 1st and 2nd. I tried using an IIf statement in the shift field
(control source) but it's not working. I want it to return a value of 1st if
the time is equal to or above 7:00 AM. Between 7:00 AM to 3:30 PM is first
shift, anything after is second. What am I doing incorrectly? It tells me I
don't have a operand or operator.

=IIf([Start_Time]>=7:00 AM; "1st", 2nd"))
 
B

BruceM

If times are entered by way of a time clock, be sure that you are getting
the expected results if somebody punches in at 6:59 AM. If times are
entered manually, you may want to allow for somebody coming in early. Maybe
you would want something like:
=IIf([StartTime] > #1:00 PM#,"2nd","1st")
 
G

Guest

Thank you, that works. I forgot that time fields have a # sign with it as
they do in queries, not quotes. I was doing quotes as well. Shame on me.

Douglas J. Steele said:
=IIf([Start_Time]>=#7:00 AM#, "1st", 2nd"))

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Adriana said:
I have a form with [Start_Time] and [Stop_Time] and a {Shift] field that
has
two choices, 1st and 2nd. I tried using an IIf statement in the shift
field
(control source) but it's not working. I want it to return a value of 1st
if
the time is equal to or above 7:00 AM. Between 7:00 AM to 3:30 PM is
first
shift, anything after is second. What am I doing incorrectly? It tells me
I
don't have a operand or operator.

=IIf([Start_Time]>=7:00 AM; "1st", 2nd"))
 

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