troubleshooting Question

MSAccess Error Function Runs without an error

Avatar of Lambel
Lambel asked on
Microsoft Access
2 Comments1 Solution216 ViewsLast Modified:
I have a procedure that I've built in error coding.  For some reason, the error process runs even when there are no errors.  Why is this?
Private Sub cmdCancel_Click()
    Dim strMessage As String
    
   On Error GoTo cmdCancel_Click_Error

   Forms!frmReportGenerator.[Report Parameters].SetFocus
Forms!frmReportGenerator.[Report Parameters].Controls.txtSaveAs.SetFocus

   On Error GoTo 0
   Exit Sub

cmdCancel_Click_Error:

    strMessage = "Error " & Err.number & " (" & Err.Description & ") in procedure cmdCancel_Click of VBA Document Form_frmSubRecipients-Add."
    strMessage = strMessage & " Application will stop processing now." & vbNewLine
    strMessage = strMessage & "Please note or copy this error message and contact application developer for assistance."
    MsgBox strMessage, vbCritical + vbOKOnly, "Error"
    End
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros