validation rule override

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

Please help; I need some code. Here's what I have:
-number field with validation rule of >0.

I also have a checkbox marked "adj required"

I need some code that will override the validation rule of the number field
when the "adj required" box is checked. Can anyone help me on that please?
Thanks in advance!

bluezcruizer
 
Can't override it if it as field level validation in the table design mode.
You will have to change to form or control level validation.
 
Hi Klatuu,
the validation is form level for that field only, not table level. How
could I setup the override?
 
Then delete that from the validation rule property and put this in the Before
Update event of the number control:

Private Sub NumberControl_BeforeUpdate(Cancel As Integer)

If Nz(Me.Number Control,0) <= 0 Then
If Me.[adj required] = False Then
MsgBox "Must be Greater than 0"
Cancel = True
End If
End IF
End Sub
 
Thank you Klatuu! That did it!
bluezcruizer

Klatuu said:
Then delete that from the validation rule property and put this in the Before
Update event of the number control:

Private Sub NumberControl_BeforeUpdate(Cancel As Integer)

If Nz(Me.Number Control,0) <= 0 Then
If Me.[adj required] = False Then
MsgBox "Must be Greater than 0"
Cancel = True
End If
End IF
End Sub
--
Dave Hargis, Microsoft Access MVP


bluezcruizer said:
It's not in code of any sort; just in the properties of the field.

validation rule: >0
 
Back
Top