Substitue user message in place of system-generated error message

G

Goldar

There are often times when I would like to isuue my own error message in
place of a system generated error message. A good example would be when a
message appears that indication a referential integrity violation or
cascading delete warning. I would like to customize these error messages and
warnings for my user. Is it possible to do this?

Thanks,

Gerry Goldberg
 
G

ghetto_banjo

yep you can do this in most cases in VB code. should be lots of
resources online, here is one: http://allenbrowne.com/ser-23a.html

If you let Access automatically program a command button by going
through the wizard, they will set this stuff up automatically, and you
can manually change the MsgBox.

here is an example of doing this when saving a record.


On Error GoTo Err_btnSaveClose_click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

Exit_btnSaveClose_Click:
Exit Sub

Err_btnSaveClose_click:
MsgBox "There was an error while saving this record. blah blah
blah", vbOkOnly
Resume Exit_btnSaveClose_Click
 
F

fredg

There are often times when I would like to isuue my own error message in
place of a system generated error message. A good example would be when a
message appears that indication a referential integrity violation or
cascading delete warning. I would like to customize these error messages and
warnings for my user. Is it possible to do this?

Thanks,

Gerry Goldberg

You can use code to replace the system message with your own.

Here's how you can find the correct error and show your own message
for any of the form level errors.

First code the Form's Error event:

MsgBox "Error#: " & DataErr ' Display the error number
Response = acDataErrDisplay ' Display Default message

Then open the form and intentionally make that error.

The message box will display the error number and then the default
error message.

Next, go back to the Form's error event and change that code to:

If DataErr = XXXX Then
Response = acDataErrContinue ' Don't display the default
message
MsgBox "Present your own message here."
Else
MsgBox "Error#: " & DataErr
Response = acDataErrDisplay ' Display Default message
End If

where XXXX is the error number.
 

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