Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global or Public Error Trapping?

Status
Not open for further replies.

Turbo

Programmer
Aug 23, 2000
93
US
I would like to insert an error trap once in a module of code to trap all errors rather than insert the trap in each sub routine. Can this be done? How?

Please advise.

Thanks,

Turbo

"There is a fine line between confidence and conceit" - Ken Mai
 
In your code
-------------------------
Code:
on error goto errHandle:

'do junk here

errHandle:

If Err.Number <> 0 Then
    Call InsertError(Err.Number,Err.Description,Err.Source,&quot;some more junk here&quot;)
else
    exit sub
end if
----------------------
In a module:
----------------------
Code:
Public Sub InsertError(ErrNum as Integer, ErrDesc as String, ErrSource as string,AddtnlComments as string)

'do what you want in the code here

end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top