Code will not go to Error Handler

RCurtin

Registered User.
Local time
Today, 04:22
Joined
Dec 1, 2005
Messages
159
Hi,
Am having a very strange problem:
The ErrorHandler does not get executed. There must be a mistake in the code but I'm not seeing it! Here is a pared down version of my code:
Code:
Public Function createAssignRecord(lstPart As ListBox)
On Error GoTo Err_createAssignRecord

    
    Error 3022
    

Exit_createAssignRecord:
    Exit Function

Err_createAssignRecord:
    Select Case Err.Number
        Case 3022     'ignore duplicate keys
        MsgBox "You have already added this record"
            Resume Next
        Case Else
            MsgBox Err.Number & "-" & Err.Description
            Resume Exit_createAssignRecord
    End Select
    
End Function

It just stops at the Error 3002 line and the Error Handler code doesn't get executed at all?
 
Maybe...

You can set how errors are handled in your database. In a code window, check Menu->Tools->Options->General(tab)->Error Trapping(section). Make sure setting is "Break on unhandled errors."
 
Try replacing: Error 3022 with: Err.Raise 3022.
 
Thanks a mill for that lagbolt. I actually did think of checking the options there and it 'break on all errors' was selected - thought that would cover it.. I changed it to 'break on unhandled errors' and it works perfectly.

(Thanks RG - I did have Err.Raise 3022 but it gave the same result)
 

Users who are viewing this thread

Back
Top Bottom