Printing with vba code in MS ACCESS 2010 .. setting number of copies?

Posted on 2011-05-12
Last Modified: 2013-12-15
Im trying to print via vba code in ms access 2010.  I have the code in place using application.printer  It prints no problems and I can do a drop down box to select which printer to send it to.  I can change the page orientation, for some reason however I cannot get it to do copies.  I have provided my code below , been working on this for 3 days changing the code around and nothing seems to work.  Any help would be greatly appreciated.

this code does indeed change the orientation and print to printer, it wont however do the copies

DoCmd.OpenReport "checkin_blank", acViewPreview
Set rpt = reports("checkin_blank")
rpt.Printer = Application.Printers("hp2050")
    With reports("checkin_blank").Printer
        .Orientation = acPRORLandscape
        .Copies = 2
     End With
DoCmd.OpenReport "checkin_blank", acViewNormal
Question by:simichuck
    LVL 26

    Accepted Solution

    <DoCmd.OpenReport "checkin_blank", acViewNormal >
    This command all by itself tells Access to print a single copy, and is not needed

    You need this
    dim myCopies as integer
    dim stdocname as string 
    stdocname = "checkin_blank"
    myCopies = 2
    DoCmd.OpenReport stdocname, acViewPreview
    Set rpt = reports(stdocname)
    rpt.Printer = Application.Printers("hp2050")
    With reports(stdocname).Printer
          .Orientation = acPRORLandscape
    End With
    With DoCmd
        .SelectObject acReport, stdocname, True
        .PrintOut acPrintAll, , , , myCopies
    End With

    Open in new window


    Author Comment

    Exactly what I was looking for. Works perfect, thank you!
    LVL 26

    Expert Comment

    You betcha!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    Printers have changed substantially in the last 30 or so years, not just in technical capabilities but in cost and usage as well.  Printers were originally used for interfacing with the operator, not necessarily for printing copy or pictures. In …
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now