IIF Statement Numbers

O

Oscar

I created an IIF statememnt in a query:
IIf([Inquiries]=0,"0",[InqRatioformula]).

[InqRatioFormula]=[Adds]/[Inquiries] so I want my final result to
display a "0" if [Inquiries]=0 so you don't get a divide by zero error
but if [Inquiries] does not equal zero then I want it to display the
quotient of Adds/Inquiries.
I also want this formatted as a percent with no decimal places.
However, it will not let me format this IIf statement in a report or
query as a percent or any kind of number.
Any help would be appreciated!
Thanks,
Oscar
 
D

Duane Hookom

You can't expect an expression to be treated like a number if you might
return a string "0".
Try:
IIf(([Inquiries]=0,0,[Adds]/[Inquiries])
or
Val(IIf(([Inquiries]=0,0,[Adds]/[Inquiries]))
 

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