I have a command button that simply creates an email and then allows the user to make edits prior to sending it.
CODE
Private Sub cmdEmailExpiryWarning_Click()
DoCmd.SetWarnings True
DoCmd.SendObject , "", "", "emailaddress", "", "", "New Corporate Action" & _
" Expiring within 5 Business Days Alert - Security: " & Me.txtPropertyName, _
"Please be advised that the expiry date for a Corporate Action on " & _
Me.txtPropertyName & " (Security Number: " & Me.txtPropertyNumber & ")" & " will be expiring " & _
"within the next 5 business days. A CCA has been/will be issued today with the details. " & _
"Please do not contact Corporate Actions at this time as the complete CCA has been/will be issued " & _
"today."
End Sub
DoCmd.SetWarnings True
DoCmd.SendObject , "", "", "emailaddress", "", "", "New Corporate Action" & _
" Expiring within 5 Business Days Alert - Security: " & Me.txtPropertyName, _
"Please be advised that the expiry date for a Corporate Action on " & _
Me.txtPropertyName & " (Security Number: " & Me.txtPropertyNumber & ")" & " will be expiring " & _
"within the next 5 business days. A CCA has been/will be issued today with the details. " & _
"Please do not contact Corporate Actions at this time as the complete CCA has been/will be issued " & _
"today."
End Sub
It works exactly how I want it to work - except when the user decides to cancel the email. In other words, if they close the email without sending it, I get the following error message:
Run-time error '2501';
The SendObject action was canceled.
I'm a bit of a newbie and assume that I simply need to add some code to handle this situation when the user decides not to continue with the email. (BTW, I do not need to force the user to send the email. It is perfectly acceptable for them to cancel the process.)
Any help would be appreciated. (I'm also completely open to a different strategy to process this requirement.
Thanks,
Dave