Validation Text

PeterWieland

Registered User.
Local time
Today, 23:37
Joined
Sep 20, 2000
Messages
74
My form has a validation rule with appropriate validation text. When the criteria is not met, my validation message displays, followed by the Access "THE VALUE IN THE FIELD OR RECORD VIOLATES THE VALIDATION RULE FOR THE RECORD OR FIELD".

Is there any way that the standard Access message can be disabled for this control only?

I know I can turn off warnings for everything, but in many cases the Access warning is fine.

Thanxs in advance.
 
there is an example of how to do this in the access help (in 2000 - not sure about the others).

Check the error event for a form.

What you have to do is test if a certain error code occured.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
Const conDuplicateKey = 3022
Dim strMsg As String

If DataErr = conDuplicateKey Then
Response = acDataErrContinue
strMsg = "Each employee record must have a unique " _
& "employee ID number. Please recheck your data."
MsgBox strMsg
End If
End Sub

That's the code from the sample if you can't find it.

Also you can test this elsewhere. For example your BeforeUpdate event for your control

The code would be something like:

private Sub ctlName_Event()
On Error GoTo Err_ctlName_Event

'Your event code

Err_ctlName_Event:

If Err.Number = conYouErrorCode Then
Msg = "Your description here"
MsgBox Msg
End If
end Sub
 
Looking at this from the other angle, if you're validating the control's value yourself in code, do you need the validation rule at all?

Mike
 

Users who are viewing this thread

Back
Top Bottom