Access 2010 SendObject Cancelled Error
Posted on 2012-09-17
I have a form which allows the user to view booking details for any customer.
The user can clcik a button on this form and email the customer a pdf of their booking.
The email button is only visible if the customer has a email address entered in the database.
All works fine except, if the customer has an email address saved in the system and the user clicks the "Email Booking" button but then changes their mind and closes the open email with pdf attachment the system gives a SendObject Cancelled Error and then crashes.
Below is my code. Can anyone assist please?
Private Sub cmdEmailBooking_Click()
On Error GoTo Error_Handler
Dim stLinkCriteria As String
Dim strEmailAdd As String
stLinkCriteria = "[HABooking_ID]=" & Me![HABooking_ID]
strEmailAdd = Me![EmailAddress]
DoCmd.OpenReport "rptViewBookingNew", acPreview, , stLinkCriteria
DoCmd.SendObject acSendReport, "rptViewBookingNew", acFormatPDF, strEmailAdd, "email@example.com", , "Booking Confirmation", , True
DoCmd.Close acReport, "rptViewBookingNew"
Select Case Err.Number
MsgBox "Error No. " & Err.Number & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"