Microsoft KB Archive/100919

From BetaArchive Wiki

ACC1x: Consecutively Numbering Pages for Two or More Reports

Q100919



The information in this article applies to:


  • Microsoft Access versions 1.0, 1.1





SUMMARY

This article describes how to consecutively number the pages of multiple reports. For example, if the first report has 10 pages, then the second report will begin numbering at page 11.



MORE INFORMATION

This article assumes that you are familiar with Access Basic and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information on Access Basic, please refer to the "Introduction to Programming" manual.

The following steps demonstrate how to consecutively number the pages of multiple reports:


  1. Open a new or existing module and enter the following code:

         '******************************************************
         'Declarations Section of Module
         '******************************************************
           Option Explicit
           Global CurrPage As Integer
    
         '======================================================
         'This function returns the page number to be used in the
         'consecutive report footer(s). It also increments the Global
         'Variable CurrPage.
         '======================================================
    
           Function GetPage ()
              CurrPage = CurrPage + 1
              GetPage = CurrPage
           End Function
    
         '======================================================
         'This function is called by the first report to initialize the
         'Global variable to 0.
         '======================================================
           Function InitPage ()
              CurrPage = 0
           End Function
    
         '======================================================
         'This function is called from the first report's page footer.
         '======================================================
           Function SetPage (PgNumber As Integer)
              CurrPage = PgNumber
           End Function 
  2. Open the first report in Design view by selecting the report in the Database window and choosing the Design button.
  3. From the View menu, choose Properties to display the property sheet. If the report does not already have a report header, choose Report Hdr/Ftr from the Layout menu.

    NOTE: If you do not want a report header or footer, simply resize the section to a height of 0.
  4. Click any portion of the report header section not covered by a control to display the report header properties. Set one of the following properties for the report header section:

    OnFormat: =InitPage()

    -or-

    OnPrint: =InitPage()
  5. Click any portion of the page footer section not covered by the control to display the Page Footer properties.
  6. Set one of the following properties for the page footer section:

    OnFormat: =SetPage(Page)

    -or-

    OnPrint: =SetPage(Page)
  7. Open the second report in Design view by selecting the report in the Database window and choosing the Design button. Create a text box control in the page footer, and set the following property for the text box control that you just created:

    ControlSource: =GetPage()
  8. Repeat step 7 for any additional reports you want to number consecutively.
  9. Print the reports in order. The pages will be numbered consecutively.

NOTE: To ensure that the reports are numbered correctly, you should print the reports consecutively without previewing each report. If you want to preview a report, do not choose Print; be sure to choose Cancel to return to the Database window and print the reports consecutively.



REFERENCES

Microsoft Access "User's Guide," version 1.0, pages 422-424 and 440-444

Microsoft Access "Language Reference," version 1.0, page 364

Additional query words: reports

Keywords : kbusage
Issue type : kbinfo
Technology :


Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.