Creating If Statement

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.
 
K

Ken Snell

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))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top