ACC: How to Print Odd or Even Pages of a Report

Last reviewed: October 24, 1997
Article ID: Q101075
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes how to print separately the odd and even pages of a report for duplex printing or to print reports with different margins for binder storage.

NOTE: This article explains a technique demonstrated in the sample files, RptSampl.exe (for Microsoft Access for Windows 95 version 7.0) and RptSmp97.exe (for Microsoft Access 97). For information about how to obtain these sample files, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q145777
   TITLE     : ACC95: Microsoft Access Sample Reports Available on MSL

   ARTICLE-ID: Q175072
   TITLE     : ACC97: Microsoft Access 97 Sample Reports Available on MSL

MORE INFORMATION

The best way to print separately odd and even pages of report is to set up a form that prompts you for the pages to print (odd or even) and then calls a macro to print the report. The form in the example below contains a text box control to hold the value "odd" or "even" and a command button to print the report.

NOTE: When you use the following steps to print even pages, all the odd pages generate blank pages (and vice versa). Whenever you implement this routine, your report generates blank pages between each printed page.

  1. Create a new form called Print Odd Even Pages:

        a. Add an unbound text box with Name = PrintPages.
    

        b. Add a command button with Caption = Print Report. From the
           OnClick property (or OnPush in version 1.x), call the following
           OddEven.Print macro group.
    

  2. Create a new macro called OddEven.

    NOTE: In the following example, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this example.

          Macro Name      Condition                        Action
          ----------------------------------------------------------
          Print                                         OpenReport
          TestOddEven  Forms![Print Odd Even Pages] _
                       ![PrintPages]="Even" And _
                       Page Mod 2=1                     CancelEvent
    
                       Forms![Print Odd Even Pages] _
                       ![PrintPages]="Odd" And _
                       Page Mod 2=0                     CancelEvent
    
          Print Actions
          ----------------------------------------------------------
          OpenReport
             ReportName: Customer Labels
             View: Print Preview
    
    

  3. From each report section that is printing data, call the macro group OddEven.TestOddEven from the OnPrint event procedure.

    For example, in the Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier) sample database report Customer Labels, the only section that is printing is the detail section. The page header and page footer in this report do not print any values. For the detail section, set the OnPrint event procedure as follows:

          OddEven.TestOddEven
    

  4. With the form open, enter Odd or Even in the text box. When you choose the Print Report command button, the Customer Labels report opens. Press OK for all countries. The report then runs its OnPrint events, which call the macro group OddEven.TestOddEven to print only the odd or even pages.


Additional query words: every other page left right
Keywords : RptLayou kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.