INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

DoCmd.SendObject Compile Error - Sub Or function Not Defined

DoCmd.SendObject Compile Error - Sub Or function Not Defined

(OP)
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 rs

Thank you in advance. I don't want to be emailing 96 Scorecards each month, and really appreciate any help you can offer.

RE: DoCmd.SendObject Compile Error - Sub Or function Not Defined

(OP)
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??

RE: DoCmd.SendObject Compile Error - Sub Or function Not Defined

>"& strEVPOEmail &"

This is not doing what you think it is doing.

RE: DoCmd.SendObject Compile Error - Sub Or function Not Defined

Without my checking the actual syntax, try get rid of some extra stuff:

CODE --> vba

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

RE: DoCmd.SendObject Compile Error - Sub Or function Not Defined

(OP)
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

RE: DoCmd.SendObject Compile Error - Sub Or function Not Defined

(OP)
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?



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close