Log in

View Full Version : iif statement



wfishero
02-02-2015, 01:49 PM
Hi all,

I'm trying to make a form in access for a registration dept. In short, the form has an "Arrival Time" field, a "Registration Time" field, and a "Taken Straight Back" (meaning they were registered as soon as they arrived) check box. I wrote an iif statement in the table design that if the Taken Stright Back box was checked to put the arrival time in the registration time box, but if was not checked to leave the registration time box open so the staff could write the reg time in manually [ iif([TakenStrightBacl]=Yes,[ArrivalTime) ] - I did not put a false part in beacuse I do not need one. However, when I run this it gives me an error saying "Syntax error in expression" and places a 0 in the false part of the iif statement.

How can I get this iif statement to work so if the box is not checked, I can manually enter in a time when I'm in the Form Entry view?

Thanks,
Wes

Tommy
02-02-2015, 02:43 PM
The below is sort of pseudo code. you have an extra ) in the statement or you don't have a ].
You will need to check for the checkbox value is = 1 (for true)


ArrivalTime.Value = now()


iif(TakenStrightBacl.Value=1,registration time = ArrivalTime)

You haven't asked but I will offer a little advice:
On the textbox have it disabled and if they are not taken back immediately, enable the text box and set the focus on it so you enter the time. I am not sure of the sequence, so it may not work as you (OK I ) would want it.