Tutorial by Examples

Here is typical error handler for a subform as a table: Public Const cErrCodeValueRequierd = 3162 Public Const cErrCodeDuplicateKey = 3022 Private Sub Form_Error(DataErr As Integer, Response As Integer) Select Case DataErr Case cErrCodeDuplicateKey MsgBox "Duplic...
Basic error handling should be added to all procedures in production code, since otherwise an unexpected error will cause Access to crash or invite the end-user to enter debug mode. A typical pattern for a basic error handler that traps all errors is: Sub Name() On Error GoTo errHandler '[some...
On error move to labelled code and see if there is a specific error that needs to be handled. Public Const cErrCodeNotNumber = 2262 ' This value must be a number. Public Const cErrCodeNumericOverflow = 2263 ' The number is too large. Private Sub MySub() Dim objConn As ADODB.Connection ...

Page 1 of 1