Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIf function syntax needs help 2

Status
Not open for further replies.

hengsin

Technical User
Mar 26, 2003
128
MY
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.

 
hengsin,

DIM ok as boolean

ok = iif( me.test1 & me.test2),true,false)


While you are in the design mode with th cursor on iif, press F1. You have a marvelous HELP ast your finger tips.

Rollie E
 
Couple of things come to mind. The syntax of your statement looks correct, but as its written, everything is using strings, not boolean values.

"True" -> is a string because it's in quotes
True -> boolean value, not in quotes.

Removing the quotes may take care of the situation.

=IIf(Test1 = True and Test2 = True, True, False)

However, since you're using booleans, you really don't need the IIf statement. You can simply And the two together.

Resuslt = Test1 And Test2

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top