IIf syntax needs help

L

Lim Heng Sin

HI, I am looking for the correct syntax only as i can't
figure out.

One table with 3 fields. All are checkbox
Test1,Test2,Result

Result will become true only if Test1 and Test2 are true.
So, i use the =Iif(Test1 = "True" and Test2
= "True", "True","False") to be put on the Default value
in Result field.

I believe the logic and the usage of the Iif function is
correct but i always get the syntax error message. Can
anyone here help me the correct syntax. I already search
through the Help file but it didn;t help much.
 
J

John Vinson

Result will become true only if Test1 and Test2 are true.
So, i use the =Iif(Test1 = "True" and Test2
= "True", "True","False") to be put on the Default value
in Result field.

I believe the logic and the usage of the Iif function is
correct but i always get the syntax error message. Can
anyone here help me the correct syntax. I already search
through the Help file but it didn;t help much.

There are two problems here. You have quotes around "True" which makes
it a Text value. A Yes/No field is NOT a Text string; it's stored as
-1 for True, 0 for False, and the words True and False (without
quotes) are synonyms for -1 and 0.

More critically, a Table's Default property cannot refer to any other
field. If Result can always be determined by comparing Test1 and Test2
then it *should not exist in your table AT ALL* - it's redundant!
Instead, use a Query based on your table; you can use the logical AND
operator to calculate the value of Result on the fly by typing into a
vacant field cell:

Result: [Test1] AND [Test2]

This will give True as the value of Result if and only if both other
fields are True.
 

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