Error Trapping

R

Robert

I am using two procedures.

Procedure 1: activated with OnError property of the form
and used to test the form and trap as many different
errors as possible. Then, Procedure 1 is replaced with
Procedure 2.

Procedure 2: to trap the Error code, and send the user a
custom MsgBox.

Procedure 2 works fine as long as I do something as simple
as try to navigate to another record. However, if I click
on the Close Button in the Control Box, there are two
error codes generated and I don't know how to revise the
code to have it address Case 3022 before moving to Case
2169. I have considered eliminating the Close Button in
the Control Box and inserting a command button that would
save the record and then close the form. I tried this,
with the same results. The following are the two
procedures being used.

If you can offer some direction, I thank you in advance
for any assistance...

Procedure 1:
Private Sub Form_Error(DataErr As Integer, Response As
Integer)
MsgBox DataErr
End Sub


Procedure 2:
Private Sub Form_Error(DataErr As Integer, Response As
Integer)

Select Case DataErr
Case 3022
MsgBox "3022 message goes here"
DoCmd.GoToControl "[Cost Code]"
Response = acDataErrContinue

Case 2169
MsgBox "2169 message goes here"
DoCmd.GoToControl "[Cost Code]"
Response = acDataErrContinue

Case Else
Response = acDataErrDisplay

End Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top