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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum divided by 0 error

Status
Not open for further replies.

meldrape

Programmer
May 12, 2001
516
0
16
US
Hi there,

I have the following formula in the control source of a text box on my report:

=Sum([NSQFT])/Sum([NACTTIME])

I get an error of course if the [NACTTIME] is zero but I'm not smart enough to know how to build the formula with error handling. Any ideas would be appreciated. Thanks in advance.

 
Try this:

IIF(Sum([NACTTIME])=0,0,Sum([NSQFT])/Sum([NACTTIME]))

The IIF function has 3 parts (separated by 2 commas). It basically says, "When this condition is true[1st part], in this case "Sum([NACTTIME])=0", do whatever it says in the [2nd part]. (That's when you might want to see "0" instead of DIV/0 or whatever your results are now. The [3rd part] says what to do if the condition is false (when the denominator of your formula is not 0).
 
Thanks so much. Worked like a charm. Thanks also for the explanation!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top