MsgBox destination db in update query (1 Viewer)

Pat Hartman

Super Moderator
Staff member
Local time
Today, 09:04
Joined
Feb 19, 2002
Messages
42,981
Given my background with online transactions which need to be extremely tight code, I tend to let errors happen and trap the error. Errors are the exception and happen so infrequently, that it is a waste of time to try to prevent all of them. So I pick my battles and if I choose to not prevent an error, this is code that "catches" it. As you can see, you have a variety of options, ignore the error or respond with a message, continue processing after the message or exit the procedure.
Code:
On Error GoTo ErrProc

    ........

ExitProc:
    Exit Sub
ErrProc:
    Select Case Err.Number
        Case 2501
            Resume Next
        Case 3167
            MsgBox "This record was deleted and can no longer be selected.", vbOKOnly
            Me.Requery
            Resume ExitProc
        Case Else
            MsgBox Err.Number & "--" & Err.Description
            Resume ExitProc
    End Select
 

Users who are viewing this thread

Top Bottom