In Access 2007 My Error Trapping is set on Break on Unhandled Errors
I want the code to stop at the line where an error occurs and exit functions instead of resuming to the next line of code. However it doesn't seem to be working for me. I purposely created an error at line 6 to see if it would exit the function after this line but it only prompts the error handler message and continues to resume to the next line after error occured. Here is my code:
GoToBackend():
'Go to current linked backend database
Private Function GoToBackend()
On Error GoTo BackendErrorHandler
'To update BEPath requires two sets of proc.
'Delete Exisiting
RunQuery "DeleteBEEPath" 'Here is where I created error by miss spelling it
'Insert Into
RunQuery "InsertBEPath"
'Prompt alert
MsgBox "Front end tables succesfully linked. Access now needs to run the backend database to complete the linking process. Please ensure macros/vba are enabled if prompted.", 48
Hyperlink.GoHyperlink (Hyperlink.PrepHyperlink(GetBackendPath))
ExitFunction:
Exit Function 'Why won't this exit the function?
BackendErrorHandler:
Dim Msg As String
Msg = Err.Number & ": " & Err.Description
MsgBox Msg
Resume ExitFunction
End Function
RunQuery():
'Run a given query name
Private Function RunQuery(qName As String)
On Error GoTo RunQueryErrorHandler
DoCmd.SetWarnings False
DoCmd.OpenQuery qName
DoCmd.SetWarnings True
ExitFunction:
Exit Function
RunQueryErrorHandler:
Dim Msg As String
Msg = Err.Number & ": " & Err.Description
MsgBox Msg
Resume ExitFunction
End Function