Error Handling

Superglide

New member
Local time
Yesterday, 19:41
Joined
Dec 6, 2010
Messages
6
Newbie programmer that I am, I'm at least familiar with the importance of error handling in my code. However, I'm unfamiliar with best practice.

Currently, I error handle every sub. Like below (modeled after what comes in the sample MS Access databases for error handling).

Private Sub cmbSample_AfterUpdate()
On Error GoTo Err_cmbSample_AfterUpdate

'Here is a bunch of code
if x then
do this
else
end if

Exit_cmbSample_AfterUpdate:
Exit Sub

Err_cmbSample_AfterUpdate:
MsgBox err.Description
Resume Exit_cmbSample_AfterUpdate

End Sub


This seems cumbersome to me. Seems like I could have a public sub just to error handle and my on error statement could just be "on error publicerrorsub" which then grabs the error and displays it (if that's what i want).

Best practice I should be following? General advice?
 
There is a set of utilities called MZTools for VBA that has a variety of tools.
It is free and available at http://www.mztools.com/v3/download.aspx

There is a facility to add Error Handling at the procedure level - but many more features as well. Try it.
 

Users who are viewing this thread

Back
Top Bottom