outputting to PDF, needs a WHERE

tomking505

New member
Local time
Today, 01:06
Joined
Oct 7, 2010
Messages
5
Thanks to Bob, my program works perfectly.

Now, rather than sending the reports to the printer, I want to save them as PDFs. I'm generating hundreds of these, so I need to specify the filename of the PDF.

I need to turn this:

Code:
DoCmd.OpenReport "myReport", acViewPreview, , "[CclientID] =" & stJustOne, acDialog

Into this:

Code:
DoCmd.OutputTo acOutputReport, "myReport", acFormatPDF,

Problem is, there is no place for the WHERE.

Without the WHERE, instead of printing hundreds of individual PDFs, it prints everything in one giant PDF, hundreds of times.

How can I trade OutputTo for OpenReport?

Thanks very kindly in advance!

Tom
 
>I think if you open the report as you are and then output, it will create a filtered PDF.

I am grateful for your response, but the PDF is always the first client.

What I have now is:

Code:
DoCmd.OpenReport "MyReport", acViewPreview, , "[ClientID] =" & stJustOne, acHidden
DoCmd.OutputTo acOutputReport, "MyReport", acFormatPDF, "C:\filename.pdf", False
DoCmd.Close acForm, "MyReport", acSaveNo

As for your other suggestion, I'm unclear what it means. There are two code snippets, seemingly before and after, but they are identical.
 
Well, a miracle ocurred! I solved my own problem. I'm posting the code so that others that follow might find it. (That's how I stumbled on it, myself.)

I needed to add a SelectObject to the code I posted above. That's the connection between the OpenReport and the OutputTo.

This works perfectly:

Code:
DoCmd.OpenReport "MyReport", acViewPreview, , "[ClientID] =" & stJustOne, acHidden DoCmd.SelectObject acReport, "MyReport" 'this added line is all that changed
DoCmd.OutputTo acOutputReport, "MyReport", acFormatPDF, "C:\filename.pdf", False DoCmd.Close acForm, "MyReport", acSaveNo
Thanks to pbaldy and boblarson for their gracious assistance!
 

Users who are viewing this thread

Back
Top Bottom