468,765 Members | 949 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Turn Off Default Validation Error Messages

Hello'

I have a field in which I require validation in a before update
event.
The validation code I have works fine, no problem there.

However I would like to turn off the default validation error
message...as it shows up in addition to the message I am providing.

For some reason, (SetWarnings = False) does not apply to this error...
Error: "The value in the field or record violates the validation rule
for the record or field..."

Here is my code;

Private Sub txtSample_BeforeUpdate(Cancel As Integer)
SetWarnings = False

Me.txtSample.BackColor = 16777215

Dim varReturnValue As Variant

varReturnValue = DLookup(Me!txtSample, "tblResults", "[Sample] =
" & Chr$(34) & Me! txtSample & Chr$(34))

If Not IsNull(varReturnValue) Then

MsgBox "This Sample # is already allocated, please input a
different sample number. If you would like to edit the entered sample
#, please use the data review prompts from the main menu."

Cancel = True
End If
End Sub

I assumed that SetWarnings would remove this message but it does not.
Is there another Default messages function I am unaware of?

Thanks




Oct 17 '08 #1
2 6323
On Fri, 17 Oct 2008 10:27:41 -0700 (PDT), "ry***********@gmail.com"
<Ry***********@gmail.comwrote:

Read the default message carefully. It suggests there is a validation
rule, either at the table level or at the field level. Design the
underlying table and check it out.

-Tom.
Microsoft Access MVP

>Hello'

I have a field in which I require validation in a before update
event.
The validation code I have works fine, no problem there.

However I would like to turn off the default validation error
message...as it shows up in addition to the message I am providing.

For some reason, (SetWarnings = False) does not apply to this error...
Error: "The value in the field or record violates the validation rule
for the record or field..."

Here is my code;

Private Sub txtSample_BeforeUpdate(Cancel As Integer)
SetWarnings = False

Me.txtSample.BackColor = 16777215

Dim varReturnValue As Variant

varReturnValue = DLookup(Me!txtSample, "tblResults", "[Sample] =
" & Chr$(34) & Me! txtSample & Chr$(34))

If Not IsNull(varReturnValue) Then

MsgBox "This Sample # is already allocated, please input a
different sample number. If you would like to edit the entered sample
#, please use the data review prompts from the main menu."

Cancel = True
End If
End Sub

I assumed that SetWarnings would remove this message but it does not.
Is there another Default messages function I am unaware of?

Thanks




Oct 20 '08 #2
"ry***********@gmail.com" <Ry***********@gmail.comwrote:
>However I would like to turn off the default validation error
message...as it shows up in addition to the message I am providing.

For some reason, (SetWarnings = False) does not apply to this error...
Error: "The value in the field or record violates the validation rule
for the record or field..."
That's not a warning message. That's an error message. It is also happening
outside your code and is happening when Access is attempting to save the record.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
Oct 21 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by joes | last post: by
2 posts views Thread by Ely | last post: by
2 posts views Thread by ticars | last post: by
4 posts views Thread by Gregc. | last post: by
3 posts views Thread by Beemer Biker | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.