DoCmd.OutputTo acOutputReport acFormatPDF

gdg59535
NewLounger
Posts: 2
Joined: 14 Mar 2021, 13:09

DoCmd.OutputTo acOutputReport acFormatPDF

Post by gdg59535 »

i have a simple report, (invoice) that i want to email.
the problem is that it takes very long to make the pdf file


this statement

DoCmd.OutputTo acOutputReport, naamrapport, acFormatPDF, bestand


takes very long.


who has any idea ?

User avatar
HansV
Administrator
Posts: 78402
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DoCmd.OutputTo acOutputReport acFormatPDF

Post by HansV »

Welcome to Eileen's Lounge!

The time it takes to save a report as PDF will depend on the complexity of the report and its record source, and on the speed of your computer. So it's difficult to offer specific suggestions.

Does it work better if you create the email message directly?

Code: Select all

    DoCmd.SendObject ObjectType:=acSendReport, ObjectName:=naamreport, OutputFormat:=acFormatPDF, _
        To:="someone@somewhere.be", Subject:="Invoice", MessageText:="Please see the attached invoice", EditMessage:=True
Best wishes,
Hans

gdg59535
NewLounger
Posts: 2
Joined: 14 Mar 2021, 13:09

Re: DoCmd.OutputTo acOutputReport acFormatPDF

Post by gdg59535 »

the problem is that i can not filter this way, can i ?

User avatar
HansV
Administrator
Posts: 78402
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DoCmd.OutputTo acOutputReport acFormatPDF

Post by HansV »

If you want to filter the report, you can open it in print preview with a filter, then email the active report by omitting the ObjectName argument.

Code: Select all

    DCmd.OpenReport ReportName:=naamreport, View:=acViewPreview, WhereCondition:="..."
    DoCmd.SendObject ObjectType:=acSendReport, OutputFormat:=acFormatPDF, _
        To:="someone@somewhere.be", Subject:="Invoice", MessageText:="Please see the attached invoice", EditMessage:=True
Best wishes,
Hans