IIf inside of IIf

  • Thread starter Thread starter Matthew Loraditch
  • Start date Start date
M

Matthew Loraditch

I have the following statement in a query and i've read elsewhere that i can
have an if inside of an if
Purchase Total: IIf([Create Subs].[Subtotal]="0",[PO Table].[Credit Total],
(IIf([PO Table].[Tax]=0,0,0.05)*[Create Subs].[Subtotal]+[Create
Subs].[Subtotal]+[PO Table].[Shipping Charge]))
The if not true part: IIf([PO Table].[Tax]=0,0,0.05)*[Create
Subs].[Subtotal]+[Create Subs].[Subtotal]+[PO Table].[Shipping Charge]
is what i had previously used for this field and that worked fine.
Now with my new version i get a data type mismatch error, which i am
presuming is somewhere in my condition and if true portion: IIf([Create
Subs].[Subtotal]="0",[PO Table].[Credit Total]
The field that is being checked for a zero value is formatted as currency
however i have tried changing what the 0 is formatted as ( 0.00, $0.00, etc)
and still get the same error
can someone please help with what may be wrong here, logically (in the
mental sense) it looks ok but access obviously doesn't agree.
Thanks
Matthew Loraditch
 
try removing the double quotes from around the 0 as in

IIf([Create Subs].[Subtotal]=0,[PO Table].[Credit .....
 
Thanks much to both of you, it was the quotes i had seen them in an example
somewhere and used them. Works perfectly now!
Matthew
 
Back
Top