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 
Simplex Printing From VBA
David Semon 
      
3 years ago
I am trying to change my default printer from duplex (default) to simplex in VBA for a particular report.  I researched the wb and thought I had the answer, but it still prints the report in duplex.  I would appreciate any guidance on where I might be making a mistake.  Here is my code:
' ----------------------------------------------------------------
' Procedure Name:    cmdPrintReport_Click
' Purpose:           Print Report
' Author:            David J. Semon
' Date:              12/11/2022
' Updated:           04/26/2023
' Comments:
' ----------------------------------------------------------------
Private Sub cmdPrintReport_Click()

    ' Needed to avoid error if user cancels and closes the printer window
    On Error Resume Next
    
    ' Get the name of the default printer
    Dim prn   As Printer

    For Each prn In Application.Printers
        If prn.DeviceName = "HP Officejet Pro 8620 (Network)" Then
            Set Application.Printer = prn
            Exit For
        End If
    Next prn
    
    ' Set the print quality to print on one side of the paper by setting the duplex printing option to simplex
    'DOES NOT WORK
    Application.Printer.Duplex = acPRDPSimplex
    
    ' Print the report
    If cboSelectPatient = 0 Or cboSelectPatient = "" Or IsNull(cboSelectPatient) Then
        DoCmd.OpenReport "rptMedicalHealthIndicators", acViewPreview, , " TestDate > Date()-60"
    Else
        DoCmd.OpenReport "rptMedicalHealthIndicators", acViewPreview, , "PersonID=" & PersonID & "AND TestDate > Date()-60"
    End If
      
    ' Ask if the user wants to print the report on paper
    If MsgBox("Do you want to print a hard copy?", vbYesNo + vbQuestion, "Print Hardcopy?") = vbYes Then
        DoCmd.RunCommand acCmdPrint
    End If
    
    ' Close the report preview window
    DoCmd.Close acReport, "rptmedicalhealthindicators", acSaveNo
    
End Sub

Scott Axton  @Reply  
        
3 years ago
You might check out the Printer Object on the MS site.
I haven't done any work with setting specific propertties so cant advise further.
David Semon OP  @Reply  
      
3 years ago
Scott, thanks for your suggestion.  That's where I started my journey.  I'll go back and reread to see what I missed.
Scott Axton  @Reply  
        
3 years ago
David just trying to help think out side of the box a bit.
Could you add in a second printer in Windows with the settings you want? Then print to that copy of the printer with the saved settings?

Also following the link above and clicking on the Duplex link it takes you to another page there is a link at the top
SCPrintDuplex  Click that and there are options for AcPrintDuplex enumeration .

It looks like you might get by with acPRDPSimplex.

Grasping at straws here for you.  I'm way out of my comfort zone on this one.
David Semon OP  @Reply  
      
3 years ago
Scott,  thanks again for your input.  I just tried 5 different ways to do this (all suggested by GPT chat) and they all failed.  Not sure why.  I think it might be something about the print driver not recognizing the codes Access is sending to it.  I'll keep trying to find an answer.  It seems like it should be a reasonably easy thing to do.  I'll look at your idea of a second printer.   Thanks again.  All ideas welcome.
Alex Hedley  @Reply  
           
3 years ago
Could try WMI
Kevin Yip  @Reply  
     
3 years ago
Hi David, to print simplex, you set it in the report's Open (or Load) property:

Private Sub Report_Open(Cancel As Integer)
    Me.Printer.Duplex = acPRDPSimplex
End Sub

That way, it overrides whatever printer settings it has in the report.  But it does so only in this instance.  After you close the report, the Duplex property of that printer will be the same as it was before.
David Semon OP  @Reply  
      
3 years ago
Kevin, THANK YOU!  Works great.  All the hours I spent and lines of code I tried, and the solution was one line placed in the proper place.  I was just starting to try the Report Open event but with code that was way too complicated.  Thanks again.  And thanks to all who gave advice.
Scott Axton  @Reply  
        
3 years ago
Kevin for the win!  At least I was close.

David sorry I wasn't more help!
David Semon OP  @Reply  
      
3 years ago
Scott, everyone helped.  By investigating your suggestions, I learn some new information that I would have missed otherwise.  Great forum; great people.

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 2:02:11 AM. PLT: 0s