Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

VBA Printer.Copies number ignored in Access 2007 and Access 2010


View products that this article applies to.

Symptoms

In Microsoft Access 2007 and Microsoft Access 2010 when you attempt to programmatically print a form or report and use the Printer.Copies property to assign the number of copies, only one copy prints, even though you specified multiple copies.

↑ Back to the top


Cause

Microsoft is aware of this problem in Microsoft Access 2007 and Microsoft Access 2010.

↑ Back to the top


Resolution

The following workarounds can resolve the issue:

Workaround 1: Use the PrintOut action of the DoCmd object

For example, use the following code for the click event of a button on your form:
Private Sub <NameOfButton> Click()
DoCmd.OpenReport "<Name of report>", acViewPreview

DoCmd.SelectObject acReport, "<Name of report>", False


DoCmd.PrintOut , , , , <Number of copies>

DoCmd.Close acReport, "<Name of report>"



End Sub


Workaround 2: Send the same report to the printer multiple times

Paste the following in the click event of a button on your form:

Call PrintReportCopies("<reportName>", <# of copies>)


Add the following code to a module in the database:

Public Sub PrintReportCopies(strRptName As String, intNumCopies As Integer)


Dim i As Integer

For i = 1 to intNumCopies
DoCmd.OpenReport strRptName
Next i

End Sub

↑ Back to the top


More information

For more information on working with printer settings for forms and reports refer to:

How to Work with Form and Report Printer Settings
http://msdn.microsoft.com/en-us/library/bb258178(v=office.12).aspx


Steps to reproduce:

1. In a new blank database in Access 2007 or Access 2010 create a blank report, "rptTest". Add a label to the details section with the text "Test".
2. Create a new module and paste the following code in the module:

Public Sub PrintReport(sRepName As String, iCopies As Integer)
DoCmd.OpenReport sRepName, acViewPreview

Reports(sRepName).Printer.Copies = iCopies

DoCmd.Close acReport, sRepName, acSaveYes

DoCmd.OpenReport sRepName, acViewNormal

End Sub

3. Call the PrintReport procedure and provide the name of the report and the number of copies to print; for instance:
Call PrintReport "rptTest",2

Results: Only 1 copy prints


↑ Back to the top


Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

↑ Back to the top


Keywords: KB2627824

↑ Back to the top

Article Info
Article ID : 2627824
Revision : 1
Created on : 10/12/2011
Published on : 10/12/2011
Exists online : False
Views : 314