How to catch system messages

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top