INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

(OP)

Access 2010

As part of a Loop procedure I have a OpenReport command that has a "Where" statement included so that it outputs each Looped instance to our printer as below:-

DoCmd.OpenReport "rptrenewalinvite", , , "tblPolicy.LpPolID='" & PolicyID & "'"

We are now wanting to create PDF files as part of the loop rather than output to printer but this does not seem to be an option with the "OpenReport" command and it seems I need the "OutPutTo" command:-

DoCmd.OutputTo acOutputReport, "rptrenewalinvite", acFormatPDF, Path & ReportName & ".pdf"

The problem is, we cannot add the "Where" clause to the OutPutTo command!

Any ideas how we can achieve this??

Thanks - in hope!

RE: How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

Assuming ReportName is being updated in the loop, simply change

CODE

DoCmd.OpenReport "rptrenewalinvite", , , "tblPolicy.LpPolID='" & PolicyID & "'" 

to

CODE

DoCmd.OpenReport "rptrenewalinvite", acViewReport, , "tblPolicy.LpPolID='" & PolicyID & "'" 
DoCmd.OutputTo acOutputReport, "rptrenewalinvite", acFormatPDF, Path & ReportName & ".pdf" 

That should do the trick

You'll probably want to add the following after the loop completes:

CODE

DoCmd.Close acReport, "rptrenewalinvite" 

RE: How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

(OP)
Thanks Strongm

After I posted I did find the same solution elsewhere and it works well but annoyed me when each loop previewed the document! so within the report I have added a docmnd.Minimize within the On Open event which did the trick!

Its not the most elegant solution but it works, I am little surprised that MS have not included a pdf Option within the OpenReport cmd or added a "Where" option to the OutputTo but there we go we can't have everything we want I suppose.

Thanks again

RE: How do we send a report to PDF with a "Where" clause or Add Where Clause to "OutputTo

>docmnd.Minimize

Just surround the loop with

Application.Echo False
... loop stuff
Application.Echo True

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close