How to catch system messages

G

Guest

Is there a way to catch Microsoft Jet Engine Error Message?

I would like to cutomize system messages...

Example : Data Integrity problem when adding records...
The "On Error goto" does not work

Thanks in advance
 
G

Guest

In a form use the form's Error event procedure. You can trap a data error
and identify it by the value of the DataErr argument. The event procedure
also has a Response argument so by setting its return value with:

Response = acDataErrContinue

this will suppress the system message and allow you to substitute your own
message e.g.

Private Sub Form_Error(DataErr As Integer, Response As Integer)

Const UNIQUE_INDEX_VIOLATION = 3022
Dim strMessage As String

Select Case DataErr
Case UNIQUE_INDEX_VIOLATION
strMessage = "You have entered data which duplicates existing " & _
"data in a field or fields where duplicates are not allowed."
MsgBox strMessage, vbExclamation, "Error"
Response = acDataErrContinue
Case Else
Response = acDataErrDisplay
End Select

End Sub
 

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