ACC:"Continued" Header w/Group Spanning Multiple Pages (1.x/2.0)

Last reviewed: March 12, 1998
Article ID: Q88156
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

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

This article describes how to create a label that will print at the top of each report page when a data group spans multiple pages.

The events used in this technique capture the value of the group in the page footer. If this value is the same as the page header value on the next page, a label containing "Continued from previous page..." is printed at the top of the page.

MORE INFORMATION

The steps below use the sample database NWIND.MDB to demonstrate how to create a label that is printed at the top of each report page when a data group spans multiple pages:

  1. Open the sample database NWIND.MDB and create a new module.

  2. Enter the following global Declarations and functions in the module.

    NOTE: In the following sample code, underscores (_) are used as line- continuation characters. Remove the underscores from the end of the line when re-creating this code in Access Basic.

    '----------------------------------------------- 'Global Declarations '----------------------------------------------- Global CurrentGroupVal as String

    '----------------------------------------------- 'Code Section '-----------------------------------------------

    Function SetGlobalVar (InReport as Report)

              CurrentGroupVal = InReport!SetGroupVal
           End Function
    
           Function SetContinuedLabel (InReport as Report)
              If InReport.Page <> 1 then
              InReport!ContinuedLabel.Visible = _
                 IIf(Trim(InReport!CheckGroupVal) = _
                     Trim(CurrentGroupVal), True, False)
              End If
           End Function
    
    

  3. Open the List Of Products By Category report in Design view.

  4. Increase the height of the detail section to approximately 1 inch.

  5. Increase the height of the page header section by about 0.5 inch. Add a label to the page header section. Position the label below the existing fields. Set the label's Caption property to "Continued from previous page..." and set its ControlName property to ContinuedLabel. Set the label's Visible property to No.

    NOTE: In Microsoft Access version 2.0, the ControlName property is called the Name property.

  6. From the View menu, choose Field List.

  7. Add a text box bound to the Category Name field by dragging the Category Name field to the page header section. Change the text box's ControlName property to CheckGroupVal, and set its Visible property to No.

  8. Click anywhere in the page header section not occupied by a control to display the page header properties in the property sheet. Set the page header's OnPrint property as follows:

    =SetContinuedLabel(Report)

  9. Add a text box bound to the Category Name field in the page footer section. Change the text box's ControlName property to SetGroupVal, and set its Visible property to No.

  10. Click anywhere in the page footer section not occupied by a control. Set the page footer's OnPrint property as follows:

    =SetGlobalVar(Report)

  11. Preview the report. Note the "Continued from previous page..." message at the top of any page whose category details span more than one page.

Note that these steps are for illustrative purposes only; your report may require adjustments other than those mentioned. You may want to set the sections KeepTogether properties to Yes to keep sections from being split across pages. In the example, you may also want to set the Category Name header section's ForceNewPage property to Before Section to help control the page layout.

In Microsoft Access version 2.0, there is a new GroupKeepTogether property that you can use to keep groups of records together or to keep the group header with the first record in the group. You may want to experiment with this property to see how it affects your report's layout.


Additional query words: container
Keywords : RptSort kbusage
Version : 1.0 1.1 2.0
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: March 12, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.