error handling vba code example
Example 1: how to do error handling in access vba
1 Sub|Function SomeName()
2 On Error GoTo Err_SomeName
3
4 Exit_SomeName:
5 Exit Sub|Function
6 Err_SomeName:
7 MsgBox Err.Number & Err.Description
8 Resume Exit_SomeName
9 End Sub|Function
Example 2: vba error handling message
Dim Msg
On Error GoTo errorhandling
errorhandling:
If Err.Number <> 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.Helpfile, Err.HelpContext
Err.Clear
End If