Naming An Email Snapshot

A

Arturo

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.

Thank you.
 
D

Dirk Goldgar

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 -----
 
T

Tom Wickerath

Hi Arturo,

Try changing the report's caption programmatically, something like this:

Option Compare Database
Option Explicit

Private Sub Report_Activate()
On Error GoTo ProcError

'The caption is used for the Snapshot filename (caption.snp)
Me.Caption = "Report for " & [FirstName] & " " & [LastName]

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description, _
vbCritical, "Error in Report_Activate event procedure..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
A

Arturo

Thanks very much. That was exactly what I needed.

Tom Wickerath said:
Hi Arturo,

Try changing the report's caption programmatically, something like this:

Option Compare Database
Option Explicit

Private Sub Report_Activate()
On Error GoTo ProcError

'The caption is used for the Snapshot filename (caption.snp)
Me.Caption = "Report for " & [FirstName] & " " & [LastName]

ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description, _
vbCritical, "Error in Report_Activate event procedure..."
Resume ExitProc
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

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.

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top