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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IIF (If then else) help 2

Status
Not open for further replies.

Bennie47250

Programmer
Joined
Nov 8, 2001
Messages
515
Location
US
Using Access 2003

Need to write an if then else statement that will exclude 2 different codes and I can seem to get the syntax correct.

This works correctly, but it is only excluding the one HECODE of 29.

Expr1: IIf([PRTEMP2]![TCODE]="ERN" And [PRTEMP2]![HECODE]<>29,[PRTEMP2]![SUMHEAMT],0)

What I would like to do is exclude 2 different HECODE codes 20 and 29.

What would be the correct syntax for this?

Thanks
Bennie
 
IIf([PRTEMP2]![TCODE]="ERN" And [PRTEMP2]![HECODE]<>29 AND [PRTEMP2]![HECODE]<>20,[PRTEMP2]![SUMHEAMT],0)

John
 
Another way:
IIf(PRTEMP2.TCODE='ERN' AND PRTEMP2.HECODE Not In (29,20),PRTEMP2.SUMHEAMT,0)


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The "not in" was the syntax that I was trying to come up with, but could not get it correctly. Thanks PVH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top