• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

Email access 2007 report as PDF

I would like to email a contract confirmation in PDF after it has been generated using a Form.
I have saved the form to a report.
Report Name = contract confirmation

Would like to just email/pdf the current report.  Idendifier is "ContractID".

Would then like the [To] field to automatically look up the email address entered in the current form.  field name for the email address = "Email".

Would like the subject to be "Contract Confirmation" and "Trading Name" and "Contract ID".

Tried this but looks like i have entered in to many arguements due to the first contractid= to print the current record only.  Works ok when printing, but seems send object code has different structure.  Appreciate any insight.  Thanks.

Private Sub EmailContractConfirmation_Click()
DoCmd.SendObject acSendReport, "Contract_Confirmation", acFormatPDF, , "ContractID=" & Me!ContractID, ["Email=" & Me!Email], [Cc], [Bc], ["Contract Confirmation" & "Trading name=" & Me!Trading Name & "ContractID=" & Me!ContractID], [MessageText], [EditMessage], [TemplateFile]
End Sub
0
lachstock
Asked:
lachstock
  • 3
  • 2
1 Solution
 
mbizupCommented:
Give this a try for your SendObject code:

DoCmd.SendObject acSendReport, "Contract_Confirmation", acFormatPDF, Me!Email, , , ["Contract Confirmation" & "Trading name=" & Me!Trading Name & "ContractID=" & Me!ContractID], "Here is the report you asked for", True

Open in new window

0
 
mbizupCommented:
Or if you are just trying to send the current record:

DoCmd.OpenReport "Contract_Confirmation", acViewPreview,, "ContractID=" & Me!ContractID
DoCmd.SendObject acSendReport, "Contract_Confirmation", acFormatPDF, Me!Email, , , ["Contract Confirmation" & "Trading name=" & Me!Trading Name & "ContractID=" & Me!ContractID], "Here is the report you asked for", True

Open in new window

0
 
lachstockAuthor Commented:
yes just current record.

Can we make the subject dynamic to the current record?  I.e. it populates is with the current record trading name and contract ID?

Would like the subject to be "Contract Confirmation" and "Trading Name" and "Contract ID".
0
 
mbizupCommented:
Okay -  I'd suggest using variables for these for readability:


Dim strTo as string
dim strSubject as string
dim strMessage as string

strTo = Me!Email
strSubject = Me![Contract Confirmation] & Me![Trading Name] & Me![ContractID]
strMessage = "Here is the report"

DoCmd.OpenReport "Contract_Confirmation", acViewPreview,, "ContractID=" & Me!ContractID
DoCmd.SendObject acSendReport, "Contract_Confirmation", acFormatPDF, strTo, , ,strSubject, strMessage, True

Open in new window

0
 
lachstockAuthor Commented:
Thanks very much, worked out well.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now