The SendObject Action was Canceled (1 Viewer)

jHats

New member
Local time
Today, 02:51
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!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:51
Joined
Aug 30, 2003
Messages
36,124
Try adding error handling:

http://www.baldyweb.com/ErrorTrap.htm

and for whatever error number that returns (my gut is 2501, but not sure) take out the message box so it just goes to the exit handler.
 

Cronk

Registered User.
Local time
Today, 17:51
Joined
Jul 4, 2013
Messages
2,771
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

Top Bottom