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?
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?