View Full Version : IIf statement with Calculation


karl009
03-10-2010, 06:01 AM
Hi,

I have the following IIf statement;

MarkupCost1: IIf([Markup]='',([Markup]*[GBPCost]),[PSP])

What am trying to do is if the [Markup] is blank then show the [PSP] value, but if the [Markup] is not blank then do the calculation ([Markup]*[GBPCost]).

The above IIf shows the [PSP] value when there is no data in [Markup] but when I enter data I get #Error in [MarkupCost1].

What am I doing wrong.
Thanks
Karl

vbaInet
03-10-2010, 06:05 AM
MarkupCost1: IIf([Markup] & ""=''",([Markup]*[GBPCost]),[PSP])

DCrake
03-10-2010, 06:05 AM
MarkupCost1: IIf(Trim([Markup] & "") <> "",([Markup]*[GBPCost]),[PSP])

Or

MarkupCost1: IIf(Not IsNull([Markup]),([Markup]*[GBPCost]),[PSP])

Or

MarkupCost1: IIf([Markup] Is Not Null,([Markup]*[GBPCost]),[PSP])

First example deals with fields that are blank but are not null

2nd & 3rd handle Null values only. Field could be empty but not null

karl009
03-10-2010, 07:09 AM
Thanks

They worked great....

vbaInet
03-10-2010, 07:20 AM
Glad it's sorted.