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 (dynamic strObjectName naming syntax)

DoCmd.SendObject (dynamic strObjectName naming syntax)

(OP)
I am trying to combine a variable defined with my strObjectName to customize the report name which will be sent to many differnt recipients:

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 am trying to replace , strObjectName, with something like "strObjectName & "-" & strEVPFName" but I am having difficulty getting the syntax correct. Can anyone please guide me on the correct syntax?

Thank you in advance!

RE: DoCmd.SendObject (dynamic strObjectName naming syntax)

According to Help the object name must be "A string expression that's the valid name of an object of the type selected by the ObjectType argument." If you don't rename your report to something else, you can't use something else.

I expect you could temporarily rename your report and then name it back to the original

CODE --> vba

docmd.Rename "Report2",acReport,"Report1" 

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

RE: DoCmd.SendObject (dynamic strObjectName naming syntax)

(OP)
Trying to implement this idea Duane. Receiving External Name not defined error. Not sure how to define this renamed object. My report name is defined as "RegionalScorecard-"
Trying to rename temporarily to "RegionalScorecard- & " & strEVPFName & ""
But receiving error message:
Any thoughts?

I thought I would be able to simply rename within the SendObject statement as i did successfully with the Output To statement here:

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

But it is getting more complex. Suggestions greatly appreciated.




RE: DoCmd.SendObject (dynamic strObjectName naming syntax)

Don't even think of trying the entire code all together. Try just a single line to rename a report and see if it works. If so, then add it together with other code. Always compile your code before running and use Option Explicit in all modules.

The source and target names shouldn't have []s outside the quotes.

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

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