Customising Err.Description

T

Tim

When you use the wizard to create code, it puts inserts
default error handling commands into the code such as:

Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load

I would like to change the message that appears which
presumably means replacing the words "Err.Description"
with something else. I have tried using the standard
MsgBox options but I still get the standard text.

Any ideas
 
N

Nick Coe \(UK\)

At the point in your code where the Err_Form_Load subroutine
is test for the value of the error number and display your
own message box or skip the error alltogether :-

Err_Form_Load:
Select Case Err.Number
Case 9 ' 9 is an array subscript error
MsgBox "Array subscript out of range"
Case 457 ' Duplicate in collection key
Resume Next ' Ignore it
Case Else
MsgBox "Error " & Err.Number & " " &
Err.Description
End Select
Resume Exit_Form_Load

Help has some info on Err.
It does mean you will need to figure out the error numbers.
 
D

Daniel

Tim,

from my experience, you have to create an error handling trap for each error message that you want to customize... For instance you could use something like :

Err_Form_Load:
if err.number=6 then' Generate an "Overflow" error.
Msgbox "Customized message"
else
MsgBox Err.Description
end if
Resume Exit_Form_Load

you would have to add an elseif statement for every subsequent err.number that you wanted to customize.

Hope this was what you were looking for,

Daniel
 

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