Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#Div / 0

Status
Not open for further replies.

Waynest

Programmer
Jun 22, 2000
321
GB
Hi

I have a report containing a textbox which contains the following simple formula:

=[StdMins]/([AttMins])

AttMins will sometimes contain zero, and when it does the report displays #Div/0!

It looks a mess, how can I make it just display 0 instead?
 
You can use the IIF statement. Try something like...

= IIF([AttMins] = 0, 0, [StdMins]/[AttMins])

The IIF statement will evaluate the AttMins. If it is zero, then the statement will return zero, as you requested. Otherwise, it will return the calculation.

Hope it helps.

Gary
gwinn7
 
try changing the Control source from
=[StdMins]/([AttMins])
to
=IIf([AttMins] > 0, [StdMins]/([AttMins], "0")

This will evaluate the first expression if it is true then it will perform the division, if it is false it will return the last expression.

HTH,
JC
 
Well I guess I was typing my response at the same time as Gary :) - both will work

JC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top