Print and save hidden report with dynamic filter (1 Viewer)

opopanax666

Registered User.
Local time
Today, 11:30
Joined
Nov 2, 2006
Messages
42
[SOLVED] Print and save hidden report with dynamic filter

Hi everyone,

I need to generate a report with a dynamic filter, print the report without preview, and save the report as .pdf.

The following code works, but doesn't do all of the above:

Code:
DoCmd.OpenReport "rptMagazijnbon", acViewPreview, , MyFilter, acHidden
DoCmd.OutputTo acOutputReport, "rptMagazijnbon", acFormatPDF, MyPath & MyFilename, True
DoCmd.Close acReport, "rptMagazijnbon"
 
Last edited:

opopanax666

Registered User.
Local time
Today, 11:30
Joined
Nov 2, 2006
Messages
42
Sorry, hit the wrong button 8)

So, the above code works, but still shows the preview. So I would need to use "acNormal" & "acHidden" but then the "OutputTo" is not filtered...

How can I get this to work?


TIA,
James
 

opopanax666

Registered User.
Local time
Today, 11:30
Joined
Nov 2, 2006
Messages
42
After some tinkering got it to work. Apparently when switching from "acViewPreview" to "acNormal", the criteria are not forwarded anymore to the "OutputTo", and that screwed everything up.

Got this code to work as intended:

Code:
DoCmd.OpenReport "rptMagazijnbon", acNormal, , MyFilter, acHidden
DoCmd.Close acReport, "rptMagazijnbon"
DoCmd.OpenReport "rptMagazijnbon", acViewPreview, , MyFilter, acHidden
DoCmd.OutputTo acOutputReport, "rptMagazijnbon", acFormatPDF, MyPath & MyFilename, False
DoCmd.Close acReport, "rptMagazijnbon"

Not very pretty, but it works!..
 

Users who are viewing this thread

Top Bottom