Customising Err.Description

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