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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Error handling - hide an Access error message or substitute your own

VBA and Custom Functions

Basic Error handling - hide an Access error message or substitute your own

by  elizabeth  Posted    (Edited  )
Use this type of construction for simple error handling.

On Error GoTo Err_ModuleName

' VBA statements

Exit_ModuleName:
Exit Sub

Err_ModuleName:
If Err.Number = 1234 then ' trapping for specific error, or use case stmts
' MsgBox or other statements
Else
MsgBox Err.Number & ": " & Err.Description
End if
Resume Exit_ModuleName

Then under Tools Options (in the VB window, not the Db window) you select "Break on unhandled errors" (I think this is the default).
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top