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
lachstockAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lachstockAuthor Commented:
Thanks very much, worked out well.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.