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

If..Then..ElseIf Query...Is it Possible?

Status
Not open for further replies.

almatad

Vendor
Nov 2, 1999
1
US
Is it possible to perform a calculation in a Query using If...Then...ElseIf?<br>
<br>
This is basically what I want to do<br>
<br>
Amount in Tons: If «Expr» [Unit Type] = gallons then [UnitAmount] * [WasteTypeID] / 2000 ElseIf «Expr» [Unit Type] = Pounds then «Expr» [WasteTypeID] / 2000 ElseIf «Expr» [Unit Type] =Kilograms then «Expr» [UnitAmount] «Expr» *2.205 /2000 ElseIf «Expr» [Unit Type] =Yards then «Expr» [UnitAmount] * 1 EndIF<br>
<br>
I keep getting a syntax error. Any thoughts on how I can do this? Thanks!<br>

 
Try nesting IIF-formulas IIF([Unit type]='gallons',[UnitAmount] * [WasteTypeID] / 2000 ,IIF([Unit Type] = 'Pounds',[WasteTypeID] / 2000 , etc.).<br>
<br>
Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top