Change error messages

bauer

Registered User.
Local time
Today, 06:45
Joined
Aug 23, 2001
Messages
77
I'm trying to figure out how to change the error messages for a multi user application. The big problem is I'm fixing up someone elses work, and I don't want to redo it by putting in my own buttons, rather just by changing the error messages.

Thank you
 
If I understand your query to mean changing the Microsoft error messages (for shame - if they were not perfect they would not be in Access!) then you could do something like

...
On Error Resume Next
Execute statement generating potential errors
If Err.Number <> 0 Then
Msgbox "Your own custom error message"
End If
On Error GoTo 0
...

If you have a variety of "canned" errors you could give each a number, save the numbers and the message text in a table, and write a little subroutine that looks like

Public Sub ErrMsg ( intErrNo As Integer)
Dim strMsg as String
strMsg = Dlookup ("Text", "tblErrorMsgs", "ErrNo=" & intErrNo)
If Not IsNull strMsg Then
MsgBox strMsg
Else
MsgBox intErrNo & " is not a valid error number"
End If
End Sub

Whenever you encounter the error in a form, you call the Sub with the error number. Having all the error messages in a table lets you edit them in one place without rooting through code, too.

HTH,
Jim
 

Users who are viewing this thread

Back
Top Bottom