Arturo said:
I am using the SendObject method to email a report as a Snapshot. The name
of
the report is rptBilling. It names the Snapshot the same thing. How do I
rename this? I would like to name it “Bill For (first and last name of
person
in the report).†Is this possible? The respective field names are
FirstName
and LastName.
It uses the report's caption to set the file name. So you can do this by
opening the report first in print preview (possibly with
WindowMode:=acHidden), setting the report's caption property to whatever you
want, then executing the SendObject (which will use the open copy of the
report to create the snapshot), and then closing the report.
The code would look something like this:
'----- start of example code -----
Const ReportName As String = "rptBilling"
' Open the report, hidden, for customer ID specified by Me.CustID
DoCmd.OpenReport ReportName, acViewPreview, _
WhereCondition="CustomerID=" & Me.CustID, _
WindowMode:=acHidden
' Set the report caption.
Reports(ReportName).Caption = _
"Bill For " & Me.FirstName & " " & Me.LastName
' Send the report as a snapshot file.
DoCmd.SendObject acSendReport, ReportName, acFormatSNP, _
To: =Me.EmailAddress, _
Subject:="Invoice from Arturo", _
MessageText:="Pleas see your attached bill.", _
EditMessage:=False
' Close the report
DoCmd.Close acReport, ReportName
'----- end of example code -----