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 
Print a report question
Lwm Harmsma 
     
5 years ago
Hi All,

I want to print a report based on a form.

I first make a preview and if it is oke I want that report saved as a .PDF file and I use the following code:

Private Sub PDFBtn_Click()

    Dim FilePath As String
    Dim FileName As String

    FileName = RitNumber  'a field on the form
    FilePath = "C:\Users\Gebruiker\Desktop\" & FileName & ".pdf"
    DoCmd.OutputTo acOutputReport, "RitR", acFormatPDF, FilePath
      
End Sub

Private Sub RitChauffeurBtn_Click()
'Preview

    Me.Refresh
    DoCmd.OpenReport "RitR", acViewPreview, , "RitID = " & RitID

End Sub

The preview sub works as it should but when I want to save it as .PDF I get the report but with a differend record.

Any suggestions?

Thanks in advance,
Bert
Alex Hedley  @Reply  
           
5 years ago
What's the difference between RitID and RitNumber?
Lwm Harmsma OP  @Reply  
     
5 years ago
Hi Alex,

The "RitID" is just the ID field (autonumber) in the table and the "RitNumber" is a field in the same record and is a string on the form which the client wants to have as a filename.
Alex Hedley  @Reply  
           
5 years ago
Alex Hedley  @Reply  
           
5 years ago
Lwm Harmsma OP  @Reply  
     
5 years ago
Alex you are GREAT. That's what I needed. Thanks a lot!!!
Problem solved

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/9/2026 11:13:52 AM. PLT: 0s