The SendObject Action was Canceled

jHats

New member
Local time
Today, 09:09
Joined
May 30, 2017
Messages
2
Hello,

Having a slight issue. I am kinda new to access.

I have an option group and one of those (Case 8) is used to email a report. I know some info about trapping and error handling, but am not sure where to put it in option group code to stop the error from happening when I close the email without sending. Here is my code.

Private Sub btnMatLog_Click()
DoCmd.SetWarnings False

Select Case SortOptionGrp.Value

Case 1
DoCmd.OpenForm "frmMaterialOutgoing", acNormal
Case 2
DoCmd.OpenReport "Material Menu - Checklist", acViewPreview
Case 3
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 4
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 5
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 6
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 7
DoCmd.OpenForm "frmMaterial_Request", acNormal
Case 8

DoCmd.SendObject acSendReport, "rptMaterial_Request", acFormatPDF, "email@domain.com", "email@domain.com", , "Material Request", "Please see the attached material request form"

End Select



DoCmd.SetWarnings True
End Sub


Thanks for the help!
 
Private Sub btnMatLog_Click()
On error goto btnMatLog_Click_Err

DoCmd.SetWarnings False

Select Case SortOptionGrp.Value

Case 1
DoCmd.OpenForm "frmMaterialOutgoing", acNormal
Case 2
DoCmd.OpenReport "Material Menu - Checklist", acViewPreview
Case 3
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 4
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 5
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 6
DoCmd.OpenReport "Material Menu - Material Log Report", acViewPreview
Case 7
DoCmd.OpenForm "frmMaterial_Request", acNormal
Case 8

DoCmd.SendObject acSendReport, "rptMaterial_Request", acFormatPDF, "email@domain.com", "email@domain.com", , "Material Request", "Please see the attached material request form"


btnMatLog_Click_exit:
exit sub

btnMatLog_Click_Err:
If SortOptionGrp= 8 then
msgbox "Email did not work"
Resume btnMatLog_Click_exit
end if


End sub
 

Users who are viewing this thread

Back
Top Bottom