Get rid of message

ChampionDuy

Registered User.
Local time
Today, 00:12
Joined
Mar 14, 2002
Messages
94
I have a form where the user enters a SSN and when the user tries to exit the field code makes sure that the SSN does not exist in the database. If it does the user is not allowed to exit the field untill the user enters in a valid SSN. However when a user enters in a invalid SSN a message that I generate alerts the user of an invalid SSN. The problem is another message appears generated by ACCESS.

It says

"The Value in the field or record violates the validation for the record or field"

How can I get rid of that message? I tried the DoCMD.Setwarnings False, I tried to capture it with an error handler but neither one of those worked.

Here is my code.

If Not IsNull(DLookup("T_SSN", "tblTrueAgent", "T_SSN = '" & Me!T_SSN & "'")) Then
MsgBox "Agent with that SSN already Exists, Please enter in a new SSN."
Cancel = True

End If
 
Still get the Error Message

This is my Code and I still get the "The Value in the field or Record Violates the validation rule for the rule for the record or field." Error Message. For some reason it is not recognizing that it is an error message.



Private Sub T_SSN_BeforeUpdate(Cancel As Integer)

On Error GoTo ErrorHandler

If Not IsNull(DLookup("T_SSN", "tblTrueAgent", "T_SSN = '" & Me!T_SSN & "'")) Then
Cancel = True

End If
Exit Sub
ErrorHandler:
MsgBox "Agent with that SSN already Exists, Please enter in a new SSN."


End Sub
 

Users who are viewing this thread

Back
Top Bottom