Convert Form to PDF and Email

tDH

New member
Local time
Today, 23:23
Joined
Jan 21, 2013
Messages
3
Hi,

Background
I'm not from a Access Development background but I do have experience in SQL and VB, so looking to see if I could get a little assistance on the direction/limitations on the project I will be working on.

Issue
The previous developer has created a payslip to be printed out from a form (Print format set on form). Now I'm required to get this payslip sent as an email preferably with a PDF attachment.

At the moment I can get the e-mail to send to the correct employee but it is blank.

Question
Can a form be converted to a PDF? and how can it be done?

In the same project PDFs are created from reports and mailed but this is done through a module and I'm not sure if the same will work on a form. This uses PDF creator and outlook.

Any guidance and direction would be a great help. Thanks
 
Welcome to the forum.

Forms really aren't designed to be printed. For printing or emailing, you should create a Report, which can be sent as a PDF.
 
Hi John,

Yeah I've been looking into the issue since posting and have now created a report to hold the same information. Just have to write the VBA to get it into an attached PDF.

Thanks for your reply.

David
 
I did this exact thing for a form and it worked like a charm. Here is the code I used:
Code:
Private Sub CmdEmailPDF_Click()
On Error GoTo CmdEmailPDF_Click_Err
Dim Subject As String
Dim MyFileName As String
 
Subject = Me.txtInvoiceNumber & "-" & "Invoice" & ".pdf"
MyFileName = Me.txtInvoiceNumber & "_" & "Invoice" & ".pdf"
 
' Open Invoice form in preview mode
DoCmd.OpenForm "frmrptCurrentRecordInvoice", acNormal, , "[InvoiceID]= forms!frmInvoicing![InvoiceID]"
' Send a PDF of the form to an email
 
DoCmd.SendObject acForm, "frmrptCurrentRecordInvoice", "PDFFormat(*.pdf)", "", [EMAIL="Someone@email.com"]Someone@email.com[/EMAIL], "", Subject, "Hello, attached you will find a PDF of your current invoice.", True, ""
' Close the form
 
DoCmd.Close acForm, "frmrptCurrentRecordInvoice", acSaveNo
 
CmdEmailPDF_Click_Exit:
Exit Sub
CmdEmailPDF_Click_Err:
MsgBox Error$
Resume CmdEmailPDF_Click_Exit
 
End Sub
 
Scetchin thank you so much for this. Was planning to do the report to PDF work next week and you have been a great help. Just have to tinker with it to suit but apart from that working well.

Thanks again :)
 
No worries...I remember it taking me a looooooong time to figure this one out! Happy to help!
 
Six years since you posted that and I'm finally converting my accounting system away from the old fax / email printer system I was using. Your suggestion worked well in Access 2010 with a couple of minor changes.

DoCmd.SendObject acSendForm, "MCC Jobs Calc", acFormatPDF, "recipient@emailaddress.com", "", "", "", "", True, ""

Thanks!
 

Users who are viewing this thread

Back
Top Bottom