Article ID: 191474
Article Last Modified on 6/29/2004
Private Sub Form_Load()
On Error GoTo FormLoadErr
Err.Raise 76
Err.Raise 70
Exit Sub
FormLoadErr:
Select Case Err.Number 'Evaluate Error Number
Case 76
MsgBox "Form_Load Error Handler. Form Does Not Exist"
Case Else
AppWideErr (Err.Number) 'Pass Error to generic module
End Select
End Sub
Private Sub Command1_Click()
On Error GoTo Cmd1Err
Err.Raise 53 'Handled locally
Err.Raise 70 'Handled by generic module
Exit Sub
Cmd1Err:
Select Case Err.Number
Case 53
MsgBox "Command 1 Error Handler"
Case Else
AppWideErr (Err.Number)
End Select
Resume Next 'Process the next (70) error
End Sub
Private Sub Command2_Click()
'No error handling is coded in this method
'AppWideErr would not be called
Form2.Show 'Use VB's default error handling only
End Sub
Private Sub Command1_Click()
On Error GoTo ThisSubErr
Err.Raise 17
Exit Sub
ThisSubErr:
AppWideErr (Err.Number)
End Sub
Public Sub AppWideErr(lnErrNumber)
Select Case lnErrNumber 'Evaluate error passed to routine
Case 70
'The following two lines of code should be typed on one line.
'Added title to MsgBox to make it clearer where error message
'came from.
MsgBox "Generic Routine. Access Denied. See Net Administrator."
, , "AppWideErr"
Exit Sub
Case Else
'The following two lines of code should be typed on one line.
'Added title to MsgBox to make it clearer where error message
'came from.
MsgBox "Generic Routine. Unhandled Error: " + Err.Description +
" # " & lnErrNumber , , "AppWideErr"
Exit Sub
End Select
End Sub
Additional query words: kbVBp400 kbVBp500 kbVBp600 kbdse kbDSupport kbVBp kbNoKeyWord
Keywords: kbhowto KB191474