Print and save hidden report with dynamic filter

opopanax666

Registered User.
Local time
Yesterday, 19:07
Joined
Nov 2, 2006
Messages
44
[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:
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
 
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

Back
Top Bottom