Time Syntax problem in IIF statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ebasshead
    New Member
    • May 2007
    • 37

    Time Syntax problem in IIF statement

    Hi everybody,

    On my form, I have a time field where the user enters a time, if the user enters a time between 4am and 12pm, I would like my "early checkin" check box to check itself. I thought the below would do it (and Ive tried variations of it) but to no avail.

    =IIf([txtArrivalTime]>#04:00:00#,IIf ([txtArrivalTime]<#12:00:00#,-1,0))

    Do I need to convert time to a number to use the IIF statement, or is my syntax out of wack

    Thank you for your attention
    Eddie
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Originally posted by ebasshead
    Hi everybody,

    On my form, I have a time field where the user enters a time, if the user enters a time between 4am and 12pm, I would like my "early checkin" check box to check itself. I thought the below would do it (and Ive tried variations of it) but to no avail.

    =IIf([txtArrivalTime]>#04:00:00#,IIf ([txtArrivalTime]<#12:00:00#,-1,0))

    Do I need to convert time to a number to use the IIF statement, or is my syntax out of wack

    Thank you for your attention
    Eddie
    HI

    I think you have missed an argument ie:

    =IIf([txtArrivalTime]>#04:00:00#,IIf ([txtArrivalTime]<#12:00:00#,-1,0),0)

    Pehaps this is a little simpler ?

    =IIf([txtArrivalTime]>#04:00:00# And [txtArrivalTime]<#12:00:00#,-1,0)


    MTB

    Comment

    Working...