Microsoft KB Archive/88156

= ACC: &quot;Continued...&quot; Header for Groups That Span Multiple Pages =

Article ID: 88156

Article Last Modified on 5/9/2003

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q88156



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



SUMMARY
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 &quot;Continued from previous page...&quot; 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:

 Open the sample database NWIND.MDB and create a new module.  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  Open the List Of Products By Category report in Design view. Increase the height of the detail section to approximately 1 inch. 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 &quot;Continued from previous page...&quot; 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. From the View menu, choose Field List.</li> 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.</li> 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)</li> 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.</li> Click anywhere in the page footer section not occupied by a control. Set the page footer's OnPrint property as follows:

=SetGlobalVar(Report)</li> Preview the report. Note the &quot;Continued from previous page...&quot; message at the top of any page whose category details span more than one page.</li></ol>

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: kbhowto kbusage KB88156

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.