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

query Nested IIf statement 2

Status
Not open for further replies.

BrockLanders

Programmer
Dec 12, 2002
89
US
Hi, I have a query with a nested IIf statement that is not working correctly. The problem is happening in my final else statement. I'm getting values returned, but not the correct values. Below is my statement:

Code:
Sum(IIf([Chain]="1_data",([Current EVDY Net]*2),IIf([Chain]="4_data" Or "5_data" Or "6_data" Or "7_data",([Current EVDY Gross]*0.9),[Current EVDY Net]))) AS [EVDY Net]

For a Chain that is not listed above, which are chains 2_data and 3_data, I'm getting the wrong numbers. So if Chain is equal to 2_data or 3_data the result should just be the value in [Current EVDY Net] field and not a calucation like the other chains.

Any ideas?
 
Try add [Chain]= for each condition like:

Sum(IIf([Chain]="1_data",([Current EVDY Net]*2),IIf([Chain]="4_data" Or [Chain]="5_data" Or [Chain]="6_data" Or [Chain]="7_data",([Current EVDY Gross]*0.9),[Current EVDY Net]))) AS [EVDY Net]


Duane
MS Access MVP
 
you need to repeat the [chain]= so that it reads :-

Sum(IIf([Chain]="1_data",([Current EVDY Net]*2),IIf([Chain]="4_data" Or [chain]="5_data" Or [chain]="6_data" Or [chain]="7_data",([Current EVDY Gross]*0.9),[Current EVDY Net]))) AS [EVDY Net]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top