My Assistant
![]() ![]() |
|
|
Sep 15 2010, 11:09 AM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 50 |
Hi
I think I need to do a DoCmd.SendTo command to get the report to PDF - is that right? The report has a screen-only control that I need to create a PDF and then email it. When the button is hit, the report is already on screen and generated, so I need to send the current report rather than get the command to generate the report direct to PDF... I've figured out the email part, but am a bit stuck on the creating PDF... Can someone help with the syntax/code to create the PDF? Thanks |
|
|
|
Sep 15 2010, 11:47 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,048 From: Fort Worth, Texas |
If I follow you correctly you only need to add
acFormatPDF to your Docmd.SendObject statement; after the "REport Name" arguement. CODE Docmd.SendObject acSendReport, "ReportName", acFormatPDF etc. Hope this helps, If you need additional help, post your current SendObject statement and I'll update it to send PDF. Kevin |
|
|
|
Sep 15 2010, 12:51 PM
Post
#3
|
|
|
UtterAccess Enthusiast Posts: 50 |
If I follow you correctly you only need to add Hi KevinacFormatPDF to your Docmd.SendObject statement; after the "REport Name" arguement. CODE Docmd.SendObject acSendReport, "ReportName", acFormatPDF etc. Hope this helps, If you need additional help, post your current SendObject statement and I'll update it to send PDF. Kevin Tried that and Access errored out. I call a function to send the email (attaching a file to it) and that works - see the code below. CODE Public Function CreateEmail( _ Send_To As String, _ Subject As String, _ Message_Body As String, _ Attachment_Name As String) Dim olApp As New Outlook.Application Dim olMail As Outlook.MailItem Dim olAttachments As Outlook.Attachments Set olMail = olApp.CreateItem(olMailItem) Set olAttachments = olMail.Attachments olAttachments.Add Attachment_Name, olByValue, 1, "Test Description" With olMail .To = Send_To .Subject = Subject .Body = Message_Body .Display End With Set olMail = Nothing Set olApp = Nothing End Function What I need now is the command to push the report that's currently on screen to a PDF (that I can provide the name for) that I can then invoke this function to send the email... |
|
|
|
Sep 15 2010, 01:47 PM
Post
#4
|
|
|
UtterAccess Ruler Posts: 1,048 From: Fort Worth, Texas |
Try:
CODE DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, "Output Path & Filename" I assume you know how to integrate this into your setup? Let me know if you need more help, Kevin |
|
|
|
Sep 15 2010, 02:46 PM
Post
#5
|
|
|
UtterAccess Enthusiast Posts: 50 |
Try: put this into my code as: DoCmd.OutputTo acOutputReport, "Quote", acFormatPDF, "Q:\Test.pdf" and Access just errors out with "...cannot find the object '|1' "... CODE DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, "Output Path & Filename" I assume you know how to integrate this into your setup? Let me know if you need more help, Kevin Let me clarify just to be on the safe side... this code will sit in the On Click event of a (screen only) control on the report. So when the button is pushed, the report is already on the screen (in report mode) and I just want to PDF that one rather than force the report to run... Thanks |
|
|
|
Sep 15 2010, 03:12 PM
Post
#6
|
|
|
UtterAccess Ruler Posts: 1,048 From: Fort Worth, Texas |
Unless something changed in 2010 it should work. It works for me in 2007.
So your report name is "Quote"? You may need to backup and run a compact & repair on your db. Maybe even create a blank new DB and import the report and all related tables/queries/forms, etc. into that new db to test the report outputto pdf code. Hope you get this worked out, Kevin |
|
|
|
Sep 15 2010, 03:17 PM
Post
#7
|
|
|
UtterAccess Enthusiast Posts: 50 |
DOH!!! Finger trouble on my part... it would help if I included the "rpt" prefix the report name... and, you know, it works fine! What a goof-ball - sorry!!
|
|
|
|
Sep 15 2010, 03:29 PM
Post
#8
|
|
|
UtterAccess Ruler Posts: 1,048 From: Fort Worth, Texas |
No problem Homey. (IMG:style_emoticons/default/smile.gif)
Glad you got it figured out. Have a great day, Kevin |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 11:57 PM |