Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.SendObject Compile Error - Sub Or function Not Defined 1

Status
Not open for further replies.

JimStrand

Technical User
May 7, 2014
33
US
When running a program with this output statement:

DoCmd.SendObject acSendReport, "strObjectName", "PDF Format (*.pdf)", rs("strEVPOEmail"), "", "", "May Scorecard", "Attached is your May 2017 Scorecard. Please call with any questions. Thank you.", False

I receive a compile error: Sub or Function not defined. I'm using Access 2013. Do you see a problem with this function syntax? The compile error highlights [highlight yellow]rs[/highlight]
SubFunctionNotDefined_m6op8z.png


Thank you in advance. I don't want to be emailing 96 Scorecards each month, and really appreciate any help you can offer.
 
I think I moved it closer with this:

DoCmd.SendObject acSendReport, strObjectName, strOutputFormat, "& strEVPOEmail &", "", "", "May Scorecard", "Attached is your May 2017 Scorecard. Please call or email with any questions. Thank you.", False, ""

But it is not recognizing the email address which I've defined as strEVPFEmail = rst!Email

Any thoughts on this syntax??
 
>"& strEVPOEmail &"

This is not doing what you think it is doing.
 
Without my checking the actual syntax, try get rid of some extra stuff:
Code:
DoCmd.SendObject acSendReport, strObjectName, strOutputFormat, strEVPOEmail, "", "", "May Scorecard", _
     "Attached is your May 2017 Scorecard. Please call or email with any questions. Thank you.", False, ""

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016
 
That worked Duane!

DoCmd.SendObject acSendReport, strObjectName, strOutputFormat, strEVPFEmail, "", "", "May Scorecard", _
"Attached is your May 2017 Scorecard. Please call or email with any questions. Thank you.", False, ""

I also had EVPO instead of EVPF as strongmn helped me identify. Thank you so much!

Jim
 
One last twist to this solution. I am trying to customize the report name with the user name included which is the variable defined as & strEVPFName &. I did that in my output function with this:

DoCmd.OutputTo acReport, strObjectName, strOutputFormat, "C:\Users\jstrand\Documents\Scorecardtest\RegionalScorecard" & "-" & strEVPFName & ".pdf", False, ""

Now I am trying to pass the strEVPFName into my strObjectName to customize the report name with user name:

DoCmd.SendObject acSendReport, strObjectName, strOutputFormat, strEVPFEmail, "", "", "May Scorecard", _
"Attached is your May 2017 Scorecard. Please call or email with any questions. Thank you.", False, ""

Can you help with the syntax for customizing the strObjectName?

I am trying to replace , strObjectName, with something like strObjectName & "-" & strEVPFName but I am having difficulty getting the syntax right?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top