Skip to main content

How to Fix Divide by Zero Error in Crystal Reports

A Divide by Zero Error (DivideByZero) occurs when you are either dividing a number by 0 or 0 by a number.

Crystal "crashes" when this happens (or any Crystal-based product like Report Runner). 

There is a standard "trick" to fix the formula in Crystal Reports... you simply check the value of each number before you divide them, to make sure neither is a zero. If either is a 0, then the answer is 0... otherwise, go ahead and do the division.

 

The code should look like this:

If {table.value1} = 0 Or [table.value2} = 0 Then
0
Else
{table.value1} / {table.value2}

 

Here is a screenshot of how to fix a Divide by Zero error:

fix-divide-by-zero-error-crystal-reports.jpg