in the Expression of a cell i have a formula that does division between two cells and sometimes one of the cells brings back 0 and the formula comes back with "#Error" even when i catch the 0 and put with another iif it bombs so the fix is
on the top menu select Report
select Report Properties
click on Code
and paste in this function
Public Function Division(ByVal MyFirstVal As Double, ByVal MySecondVal As Double) As Double
If MySecondVal = 0 Then
Return 0
Else
Return MyFirstVal / MySecondVal
End If
End Function
Than to call it in your expression use Code.Division(Fields!yourcell1.Value, Fields!yourcell2.Value) i was getting an error that Code was not recognized in the expression but it still worked.
Here is my expression.
=iif(Fields!TY_LBS.Value = 0, iif(Fields!LY_LBS.Value = 0, 0, -1), iif(Fields!LY_LBS.Value = 0, 1, (Code.Division(Fields!TY_LBS.Value,Fields!LY_LBS.Value) - 1)))
i was trying to calculate % between the two columns