I am having a hard time with this.
I am trying to simply get SOMETHING to happen when a runtime error occurs.
I have the following code that sends an email in vba:
Code:
Private Sub EmailBrenda_Click()
Dim strMsgTxt As String
strMsgTxt = "body text"
DoCmd.SendObject acSendNoObject, , , "test@test.com", , , "subject", strMsgTxt, True
On Error GoTo Err_EmailBrenda_Click
Exit_EmailBrenda_Click:
Exit Sub
Err_EmailBrenda_Click:
If Err.Number = "2501" Then
MsgBox "Cancelled"
Else: MsgBox "Err.Description"
End If
Resume Exit_EmailBrenda_Click
This should show a message box "instead of a runtime error" that says the message was canceled. I can't get the error handler to do anything. I have tried just a simple msgbox instead of all the if err.number etc. but not even that is getting picked up. Is the onerror wrong? why wont this work?
Thanks