Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trapping More Than 1 Error

Status
Not open for further replies.

tamer64

IS-IT--Management
Aug 27, 2007
120
US
Hello!

I need to be able to trap two errors on the On Error event of my form. What I have listed is not working. Can someone assist me!

If DataErr = 3201 Then
MsgBox "Message 1."
Response = acDataErrContinue
Else
If DataErr = 3022 Then
MsgBox "Message 2."
Response = acDataErrContinue
Else
MsgBox "Error No.:" & DataErr
End If
 
Can you show us the rest of your code?
The On Error Line and an ErrHandler label or similar.


Here's a sample from a proc I have.


Code:
Public Sub DocumentTables()
'Requires function FieldType

    On Error GoTo Error_DocumentTables
----
'more code lines here
----
Error_DocumentTables:

    Select Case Err.number

    Case 3376

        Resume Next    'Ignore error if table not found
    Case 3270    'Property Not Found

        Resume Next
    Case Else

        MsgBox Err.number & ": " & Err.Description
        Resume Exit_Error_DocumentTables

    End Select

End Sub
 
Thats all of it! I am not sure why this would'nt work.

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3201 Then
MsgBox "Message 1"
Response = acDataErrContinue
ElseIf DataErr = 3022 Then
MsgBox "Message2"
Response = acDataErrContinue
Else
MsgBox "Error No.:" & DataErr
End If
End Sub
 
I also tried this, but it will only trap the first error and not the second. Any Ideas??


Private Sub Form_Error(DataErr As Integer, Response As Integer)
On Error GoTo Err_Handling


DoCmd.GoToRecord , , acNext

Exit_Form_Error:
Exit Sub

Err_Handling:
Select Case Err.Number
Case 3201
MsgBox "ID already ordered"
Response = acDataErrContinue
Case 3022
MsgBox "Me To"
Response = acDataErrContinue
Case Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End Select
Resume Exit_Form_Error

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top