Sent report as pdf file and change its name

JPR

Registered User.
Local time
Today, 13:08
Joined
Jan 23, 2009
Messages
201
Hello,

I am trying to change the name of my report before sending it as attachment by email.

DoCmd.SendObject acReport, "Myreport", "PDFFormat(*.pdf)", "", "", "", "For your Info: " & Forms![frmMain]!LastName & " - " & Forms![frmMain]!FirstName, "Your action is required. Thank you", False, ""

As indicated in the subject line of the email, I would also like to name the report with values in the two textboxes, LastName and FirstName.

Thank you for your help.
 
You can't do want you want in one command line, unfortunately.
You will have to save the file with a specific name then attach it to an email, as the sendobject method always uses the report name as the attachment name.
 
Hi JPR. What you could try is open the report in preview mode but hidden. Then, change its Caption property using the Textbox value before using the SendObject method. Don't forget to close the report after the email is sent.
 
Thanks you. I like the idea but honestly would not know how to write this code. Or should I use a macro?
 
you can also Copy the report Myreport to the Firstname Lastname:

Dim strNewReport As String
strNewReport = Forms![frmMain]!LastName & " - " & Forms![frmMain]!FirstName
DoCmd.CopyObject strNewReport, acReport, "Myreport"

DoCmd.SendObject acReport, strNewReport, "PDFFormat(*.pdf)", "", "", "", "For your Info: " & strNewReport, "Your action is required. Thank you", False, ""

'delete it later
DoCmd.DeleteObject acReport, strNewReport
 

Users who are viewing this thread

Back
Top Bottom