advanced micorosoft access training - vba access

Forum home » Delegate support and help forum » Microsoft Access Training and help » advanced micorosoft access training - VBA Access

advanced micorosoft access training - VBA Access

resolvedResolved · Low Priority · Version Standard

Tim has attended:
Access Intermediate course
Access Advanced course
Access VBA course

VBA Access

How to trap errors

RE: VBA Access

Hi Tim
I trust that you found your Access VBA course useful. To trap errors in VBA, you need to use something known as Error handling. See below for an example:


Function MayCauseAnError()
' Enable error handler.
On Error GoTo MYError_CausesAnError
. ' Include your code here that may cause errors.
.
.

MYError_CausesAnError:
. ' code here to handle error, e.g print message to user
.
.
End Function


So in MYError_CausesAnError, you place you code that could throw up errors. In MYError_CausesAnError you handle your errors, i.e. do nothing, print a message to user, offer other options.

Hope this helps
David


Server loaded in 0.08 secs.