validation rule override

B

bluezcruizer

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
 
K

Klatuu

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.
 
B

bluezcruizer

Hi Klatuu,
the validation is form level for that field only, not table level. How
could I setup the override?
 
B

bluezcruizer

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

validation rule: >0
 
K

Klatuu

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
 
B

bluezcruizer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top