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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.SendObject (dynamic strObjectName naming syntax) 1

Status
Not open for further replies.

JimStrand

Technical User
May 7, 2014
33
0
0
US
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!

 
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:
docmd.Rename "Report2",acReport,"Report1"

Duane
Vevey, Switzerland
Hook'D on Access
MS Access MVP 2001-2016
 
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.

ExternalNamenotDefined_ghumlz.png
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top