ACC: How to Print Line Number for Each Record/Group on Report

Last reviewed: October 24, 1997
Article ID: Q98790
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.

You can add a text box control that prints a sequential number for each record to the detail section of a report. This number can be reset so that a separate set of numbers is printed for each group of records. This article explains these procedures by modifying a report in the sample database Northwind.mdb (or NWIND.MDB in Microsoft Access 2.0 or earlier).

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

If you want to print an incremental counter for each record in a report group, add an unbound text box control to the detail section of the report. To begin the sequence with the number 1, set the ControlSource property to =1, and then set the RunningSum property to Over Group.

To print an incremental counter for each record in a report group, follow these steps:

  1. In the Database window, open the Products By Category report (or List Of Products By Category report in Microsoft Access 2.0 or earlier) in Design view.

  2. Add the following text box control before the Product Name control in the detail section:

          Object: Text Box
          ----------------------
          Name: MyLineNumber
          ControlSource: =1
          RunningSum: Over Group
    

    NOTE: In Microsoft Access 1.x, the Name property is called ControlName.

  3. Preview the report. Note that each group's records are sequentially numbered, beginning with the number 1.

You can also increment the counter number for each group in the report by changing the RunningSum property to Over All. To do this, replace step 2 above with the following step:

   Add the following text box control before the Category Name control in
   the Category Name Header section:

      Object: Text Box
      --------------------
      Name: MyLineNumber2
      ControlSource: =1
      RunningSum: Over All

Repeat step 3 above. Note that each individual record now prints a unique sequential number.

REFERENCES

For more information about printing an incremental counter for each record in a report, search for "Calculated controls, reports," and then "Number each detail record in a report" using the Microsoft Access 97 Help Index.


Additional query words: reports sequential line
Keywords : RptOthr 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.