Link to home
Start Free TrialLog in
Avatar of Robert Wardlow
Robert WardlowFlag for United States of America

asked on

email PDF from currently open form

I need to output the currently open Access form to a pdf and attach it to an email.

The code below will create a pdf from a named report and attach it to an email:
DoCmd.SendObject acSendReport, [name of report], acFormatPDF, "recipient@company.com",[cc email(s)],[bcc email(s)], [Message Subject], [MessageBody], True

Is it possible to print the currently open access form to a pdf attachment in an email?

Thank you in advance for your help.
SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Wardlow

ASKER

Thank you for your comment Pat, I am aware of the reasons it is not normal to print from forms. In this case we don't have the problems you reference. The forms print fine. However, I inherited this design with a lot of forms and the client would like to email pdf's. I have used VBA to manage PDF's with reports. I was curious if anyone had experience creating and emailing the currently open form.

Thanks again.
You can use the OutputTo to print a form BUT it does NOT offer a where argument so it will print everything.  The ONLY way this will work, as I mentioned earlier,  is if you have used selection criteria in your form to select only the record you are viewing.  I don't believe filters will work.  Every record in the Form's RecordSource will end up in the pdf.
Thank you Pat. I understood. The forms in question only have 1 record in the RecordSource.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you for this example Helen. However, I am aware of all of the reasons why it is better to use a report for this purpose. I asked this question to see if someone knew how to create a pdf from a form. I have specific reasons. Apparently it is not possible.

Thank you very much for your help.
I assume this is not possible since no one answered my question.

Thank you
You can "print" to a PDF printer or use OutputTo.  But OutputTo ONLY works if the recordset of the form is controlled by criteria in its RecordSource.  Filters will not work.
I tried exporting a form to PDF (there is such an option) in the interface, and while there were no error messages, the PDF was entirely blank.  If I have some time later on, I will experiment with creating a PDF from a form in code, just to see if it is possible.
Thank you Helen, I appreciate your help. I have started using the print dialog in Acrobat manually. It would have been nice to be able to automate the whole process like you can with reports but that doesn't seem to be possible.
Thanks again.
Bob