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!

division by zero error with whileprintingrecords function

Status
Not open for further replies.

dz0k52

Technical User
Jul 21, 2003
32
0
0
CA
I am using Crystal 8.5 with an Oracle 10 database.
I have looked at many threads and cannot figure this one out. I have a formula:
WhilePrintingRecords;
numbervar sumhrs/({@sum workorders});
that is placed in the group footer to give me an average of records from another formula. It works great except sometimes the result of {@sum workorders} is zero and I get the "division by zero" error. I have tried
if {@sum workorders} = 0
then 0 else WhilePrintingRecords;
numbervar sumhrs/({@sum workorders});
But I get the same result. I would be happy with a zero as a result or text saying "NO Data" or even a blank feild if
{@sum workorders}) was a zero but I can't get rid of the error. Any help would be appreciated.
 
Try:

WhilePrintingRecords;
if {@sum workorders} <> 0 then
numbervar sumhrs /{@sum workorders}
else
0

Presumably {@sum workorders} doesn't do any division, it's best to show underlying formulas as well.

-k
 
That worked great. Thanks a million.
Is there anyway to "order by" the results of the above formula? (Placed in a group footer)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top