I have this code which checks that a number entered into a field is no longer than 2 decimal places. This works fine as long as there is a number is the field but when the field is blank (null) it produces an error. I've tried different code to get round this without success. Can someone help?
Private Sub Payment_Amount_BeforeUpdate(Cancel As Integer)
DotLoc = InStrRev(Payment_Amount, ".")
If DotLoc <> 0 And (Len(Me.Payment_Amount) - DotLoc) > 2 Then
MsgBox "This field must be input to no more than two decimal places"
Cancel = True
End If
Private Sub Payment_Amount_BeforeUpdate(Cancel As Integer)
DotLoc = InStrRev(Payment_Amount, ".")
If DotLoc <> 0 And (Len(Me.Payment_Amount) - DotLoc) > 2 Then
MsgBox "This field must be input to no more than two decimal places"
Cancel = True
End If