Creating If Statement

  • Thread starter Thread starter Keith
  • Start date Start date
K

Keith

I'm trying to create a simple if statement so that I don't
get a divide by zero error when calculating a percentage.
I keep getting syntax errors. I've tried to get what I'm
doing to match the examples in the help screen, but I
guess that isn't working. Can you tell me where I have
made a mistake? Both "Sched Pounds" and "Actual Pounds"
are calculated fields in the same query. I am trying to
create the new field "% Attained".

Also, I would like to round the % Attained field's result
to 1 decimal point... how do I do that?

% Attained:
If [[Sched Pounds] = 0]] Then
[ ""]
[Else
[[Actual Pounds]/[Sched Pounds]*100]]
End If

Thank you.
 
This is in a query correct? You use the IIf function in a query, not the
If..Else syntax structure.

% Attained: IIf ([Sched Pounds] = 0, "", Round([Actual Pounds]/[Sched
Pounds]*100, 1))
 
Back
Top