Suppress the #Error message

C

ChuckW

Hi,

I have a query that divides two different fields. The denomonator in one
called QuarterlyTarget and is sometimes equal to zero or blank for some
people. When I run the report, the people who have a zero or blank target
get a #Error message which then shows up in my access report. I want to
write the query so it is left blank if there is not target so that the #Error
does not come up.

Also, in my report, I also have a calculated value which divides one number
from another. When the denomonator is zero in the report, I get a #Div/0!
error for the value in my report. I would like to get rid of this as well
and just have a blank.
 
D

Douglas J. Steele

Rather than [Field1]/[Field2], use Iif([Field2]=0, 0, [Field1]/[Field2]) in
your query.
 
J

John Spencer (MVP)

Use an immediate if statement to decide whether or not to calculate a value

FIELD: MyCalc: IIF(QuarterlyTarget is Null or QuarterlyTarget=0,Null,SomeOtherField/QuarterlyTarget)

You can use the same type of calculation in the report if necessary, although
you might be able to take care of the problem in the query.
 
Top