Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Output to PDF Problem
Sami Shamma 
             
2 years ago
Greetings Friends

Below is a part of a code I use to print & output to PDF the same report. The user has check boxes on the main menu that control the printing and PDF generation.

The top part of the code generates the correct PDF file, and it applies the "Filter" used in Docmd.OpenReport.
The "No Preview" direct print portion of the code generates a PDF that does NOT apply the "Filter" and it will output all the records without the "Filter."

It seems that acViewPreview preserves the "Filter," whereas the AcViewNormal does NOT.

Does anyone know a workaround to get the PDF to generate correctly when using AcViewNormal?

Many thanks

Details
     If vShowPreview Then ' Show Preview
        If vPrintBlock Then
            DoCmd.OpenReport "RosterR", acViewPreview, , Filter
            If vOutputBlockPDF Then
               DoCmd.OutputTo acOutputReport, "RosterR", acFormatPDF, vOutputFileBlock
            End If
        End If
    Else 'No preview, Direct print
        If vPrintBlock Then
            For vCounter = 1 To vBlockCopy
                DoCmd.OpenReport "RosterR", acViewNormal, , Filter
                If vCounter = 1 And vOutputBlockPDF Then
                    DoCmd.OutputTo acOutputReport, "RosterR", acFormatPDF, vOutputFileBlock
                End If
            Next
        End If
    End If
Kevin Yip  @Reply  
     
2 years ago
Reports don't really have a "normal" view.  When you open a report with acViewNormal, nothing is opened, and that's why no filter is applied.  Reports only have design, layout, report, and preview modes.  Only preview mode is useful for printing.  If you don't want to show the report on the screen, use the acHidden option:

     DoCmd.OpenReport "RosterR", acViewPreview, , Filter, acHidden
Sami Shamma OP  @Reply  
             
2 years ago
Happy new year Kevin
Thank you for your explanation. I will try this in the morning.

I love the way you explain things.

May thanks
Kevin Yip  @Reply  
     
2 years ago
The praise should go your way as well -- for your ability in understanding the subject at hand.  The best explanation wouldn't do much without the listener having an adequate background and foundation for the subject.
Sami Shamma OP  @Reply  
             
2 years ago
Kevin, you are too kind
Sami Shamma OP  @Reply  
             
2 years ago
Hi Kevin

The following code works perfectly:

    Else 'No preview, Direct print
        If vPrintBlock Then
            For vCounter = 1 To vBlockCopy
                DoCmd.OpenReport "RosterR", acViewNormal, , Filter
                If vCounter = 1 And vOutputBlockPDF Then
                    DoCmd.OpenReport "RosterR", acViewPreview, , Filter, acHidden
                    DoCmd.OutputTo acOutputReport, "RosterR", acFormatPDF, vOutputFileBlock
                End If
            Next
        End If

Many thanks

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 5:04:39 AM. PLT: 1s