Division by zero error

PRodgers4284

Registered User.
Local time
Today, 21:27
Joined
Feb 17, 2009
Messages
64
Im having a problem with a form when i open it in Add Mode, i get an error "Division by zero", the error points to the line below in Form_Current:

"Me.Q_Total = (100 / [Opp_Total] * [Action_Total])"

Can anyone help?


My database is below:
 

Attachments

The best solution is to test for zero in advance.
Code:
If ([Opp_Total] <> 0) AND ([Action_Total] <> 0) Then
   Me.Q_Total = (100 / [Opp_Total] * [Action_Total])
Else
   Me.Q_Total = 0
End If
 
The best solution is to test for zero in advance.
Code:
If ([Opp_Total] <> 0) AND ([Action_Total] <> 0) Then
   Me.Q_Total = (100 / [Opp_Total] * [Action_Total])
Else
   Me.Q_Total = 0
End If


RuralGuy thanks for that, it solved the problem :)
 
How about reducing it to:

Me.Q_Total = IIf(([Opp_Total] * [Action_Total]=0),0,100 / [Opp_Total] * [Action_Total])
 

Users who are viewing this thread

Back
Top Bottom