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 Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Code to Save a Report as PDF
Tom Juric 
     
13 months ago
Below is my code to SAVE a report as a PDF file. The report has been opened as ViewReport. With the exception of the Path and the report name this code work on 3 other reports. The code does not reach either the Error Handler, the Exit sub, nor the End sum. If I use this exact code but change the DoCmd.OutputTo line to a different REPORT NAME the code works works.  I have checked the report that does not work and cannot find any error there.  The database COMPILES fine with no errors. The path exists.  ANY help is appreciated

Details****************CODE BELOW******************
Private Sub butZOutInvoiceSave_Click()
      On Error GoTo Err_Handler
    
    Const FOLDER_EXISTS = 75
    Const MESSAGE_TEXT1 = "No current invoice."
    Const MESSAGE_TEXT2 = "No folder set for storing PDF files."
    Dim strFullPath As String
    Dim varFolder As Variant
    Dim rptName As String
    vReportName = TempVars!vReportDate   'equals 20250429 for todays date
    
    
    Dim vReportDate

    'vReportName = TempVars!vReportDate
    rptName = "Z-Out By Invoice"
     ' C:\RDC-POS\Liquor Reports\Owner Reports\Z-Out by Invoice
            strFullPath = "C:\RDC-POS\Liquor Reports\Owner Reports\Z-Out by Invoice\" & " " & rptName & "-" & TempVars!vReportDate & ".pdf"
            MsgBox strFullPath
            Me.Dirty = False
            DoCmd.OutputTo acOutputReport, "rptDepartmentInventoryTotals", acFormatPDF, strFullPath, False
            
            
Exit_Here:
    Exit Sub
    
Err_Handler:
    Select Case Err.Number
        Case FOLDER_EXISTS
        Resume Next
        Case Else
        MsgBox Err.Description
        Resume Exit_Here
    End Select
            
End Sub
Kevin Robertson  @Reply  
           
13 months ago
rptName is a String.

strFullPath = "C:\RDC-POS\Liquor Reports\Owner Reports\Z-Out by Invoice\""" & rptName & """-" & TempVars!vReportDate & ".pdf"

Double Double Quotes
Tom Juric OP  @Reply  
     
13 months ago
You sir are a scholar!!  Thank you for pointing that out.  It works now

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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 8:05:50 AM. PLT: 1s