Microsoft KB Archive/279506

= How to programmatically change paper bins when you print reports in Access 2002 by using Visual Basic for Applications =

Article ID: 279506

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q279506



Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SUMMARY
This article shows you how to programmatically change what paper bin that the printer uses when you print reports in Access 2002 by using Microsoft Visual Basic for Applications. For example, suppose that you want to print the first page of a report from a paper bin that supplies custom letterhead and the remaining pages of the report from a paper bin that supplies standard paper. The method in this article enables you to do so.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  Open the sample database Northwind.mdb. Create a new, blank form.  Add a command button to the form, and then set the OnClick property of the command button to the following event procedure: Private Sub Command0_Click Dim strReportName As String Dim prt As Access.Printer strReportName = &quot;Alphabetical List Of Products&quot; 'Open the report in design and change the paperbin property 'to print from the lower bin DoCmd.OpenReport strReportName, acViewDesign Set prt = Reports(strReportName).Printer prt.PaperBin = acPRBNLower

'Use the PrintOut method to print only the first page of the report DoCmd.PrintOut acPages, 1, 1 'Change the PaperBin property to print from the upper bin prt.PaperBin = acPRBNUpper 'Use the PrintOut method to print the remainder of the report. 'Here we use pages 2 through 32767. Since 32767 is the maximum number 'of pages that can be printed, we can use it here to tell the code 'to print all remaining pages, DoCmd.PrintOut acPages, 2, 32767 DoCmd.Close acReport, strReportName, acSaveNo End Sub  Save the form and close it. Open the form in Form view. Click the command button.</li></ol>

Note that the report's first page is printed from the lower paper bin, but that the remainder of the report is printed from the upper paper bin.

<div class="references_section">