IIf Function

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I get an error when using the following in a query:
RoyaltyPrice: IIf([UnitPrice]="10","2",IIf([UnitPrice]
"6.38","[UnitPrice]-4.25",IIf([UnitPrice]
"4.87","[UnitPrice]-([UnitPrice]*.6666)",IIf([UnitPrice]
"0","[UnitPrice]-3.25","0"))))

The function works in Excel.
 
Hi,



SWITCH( unitPrice=10, 2,
unitPrice > 6.38, unitprice-4.25,
unitPrice > 4.87, unitprice-.6666*UnitPrice,
unitPrice>0, unitPrice-3.25,
True, 0 )




Hoping it may help,
Vanderghast, Access MVP


Tom said:
I get an error when using the following in a query:
RoyaltyPrice: IIf([UnitPrice]="10","2",IIf([UnitPrice]
"6.38","[UnitPrice]-4.25",IIf([UnitPrice]
"4.87","[UnitPrice]-([UnitPrice]*.6666)",IIf([UnitPrice]
"0","[UnitPrice]-3.25","0"))))

The function works in Excel.
 
Tom said:
I get an error when using the following in a query:
RoyaltyPrice: IIf([UnitPrice]="10","2",IIf([UnitPrice]
"6.38","[UnitPrice]-4.25",IIf([UnitPrice]
"4.87","[UnitPrice]-([UnitPrice]*.6666)",IIf([UnitPrice]
"0","[UnitPrice]-3.25","0"))))


The function works in Excel.


Remove all of the quotes, unless you really mean to compare [UnitPrice]
(which appears to be numeric) to text strings.

RoyaltyPrice:
IIf([UnitPrice]=10,2,IIf([UnitPrice]>6.38,[UnitPrice]-4.25,IIf([UnitPrice]>4.87,[UnitPrice]-([UnitPrice]*.6666),IIf([UnitPrice]>0,[UnitPrice]-3.25,0))))
 
Thanks!!!
-----Original Message-----
Tom said:
I get an error when using the following in a query:
RoyaltyPrice: IIf([UnitPrice]="10","2",IIf([UnitPrice]
"6.38","[UnitPrice]-4.25",IIf([UnitPrice]
"4.87","[UnitPrice]-([UnitPrice]*.6666)",IIf ([UnitPrice]
"0","[UnitPrice]-3.25","0"))))


The function works in Excel.


Remove all of the quotes, unless you really mean to compare [UnitPrice]
(which appears to be numeric) to text strings.

RoyaltyPrice:
IIf([UnitPrice]=10,2,IIf([UnitPrice]>6.38,[UnitPrice]- 4.25,IIf([UnitPrice]>4.87,[UnitPrice]-([UnitPrice]
*.6666),IIf([UnitPrice]>0,[UnitPrice]-3.25,0))))
 
Back
Top