T
Tony Williams
I have a tick box control that when checked opens Outlook and attaches a
report. If the user clicks send then everything is OK. BUT if the user
clicks the close on Outlook without sending the email I want to trap the
error message 2501 and ask the user what to do. Here is my code so far:
Private Sub Loadtxt_Click()
On Error GoTo Exit_Handler
If Me!Loadtxt = True Then
DoCmd.SendObject acSendReport, "rptOnlineUpload", acFormatRTF, , , ,
"OnLineUpload", "Please upload this document to Online", True
End If
Exit_Handler:
If Err.Number = 2501 Then
If vbCancel = MsgBox("You have not sent the email, click OK to send or
Cancel to cancel the message", vbOKCancel, "Email not sent") Then
Cancel = True
Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End If
End If
End Sub
If they close Outlook without sending the message then Outlook closes and no
message pops up and the email isn't sent. It just closes whether or not they
have filled in an email address. If they click Cancel then Outlook closes
but the tick box is still checked which it shouldn't be because the email
hasn't gone.
Can anyone help me here?
I did get some of the code from a suggestion from "Brad" but couldn't get
his suggestion to do what I wanted either (Sorry Brad)
TIA Tony Williams
report. If the user clicks send then everything is OK. BUT if the user
clicks the close on Outlook without sending the email I want to trap the
error message 2501 and ask the user what to do. Here is my code so far:
Private Sub Loadtxt_Click()
On Error GoTo Exit_Handler
If Me!Loadtxt = True Then
DoCmd.SendObject acSendReport, "rptOnlineUpload", acFormatRTF, , , ,
"OnLineUpload", "Please upload this document to Online", True
End If
Exit_Handler:
If Err.Number = 2501 Then
If vbCancel = MsgBox("You have not sent the email, click OK to send or
Cancel to cancel the message", vbOKCancel, "Email not sent") Then
Cancel = True
Else
MsgBox Err.Description, vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler
End If
End If
End Sub
If they close Outlook without sending the message then Outlook closes and no
message pops up and the email isn't sent. It just closes whether or not they
have filled in an email address. If they click Cancel then Outlook closes
but the tick box is still checked which it shouldn't be because the email
hasn't gone.
Can anyone help me here?
I did get some of the code from a suggestion from "Brad" but couldn't get
his suggestion to do what I wanted either (Sorry Brad)
TIA Tony Williams