ACC:"Continued" Header w/ Groups That Span Multiple Pages(95/97)

ID: Q182823


The information in this article applies to:
  • Microsoft Access versions 7.0, 97


SUMMARY

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

This article shows you 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 following steps use the sample database Northwind.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 Northwind.mdb and create a new module.


  2. Enter the following Public declaration and functions in the module:
    
           Public CurrentGroupVal as String 
    
           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. Create a new report in Design view and base it on the Customers table.


  4. If the field list is not already visible, click Field List on the View menu.


  5. Drag the CompanyName and City fields to the detail section.


  6. Right-click anywhere in the detail section that is not occupied by a control to display the property sheet of the detail section.


  7. Set the Height property of the detail section to 0.75. Close the property sheet.


  8. On the View menu, click Sorting And Grouping.


  9. In the Sorting And Grouping dialog box, click the first Field/Expression row and select Country from the drop-down list. Set the GroupHeader property to Yes; then close the Sorting And Grouping dialog box.


  10. Drag the Country field from the field list to the Country header section.


  11. Set the Height property of the Country header section to 0.5.


  12. Set the Height property of the page header section to 0.5.


  13. Add a label to the page header section and set its Caption property to Continued from previous page...; set the Name property of the label to ContinuedLabel and set its Visible property to No.


  14. Add a text box to the page header section and set its properties as follows:
    
           Name: CheckGroupVal
           ControlSource: Country
           Visible: No 


  15. Set the OnPrint property of the page header as follows:
    
            =SetContinuedLabel(Report) 


  16. Add a text box to the page footer section of the report and set its properties as follows:
    
           Name: SetGroupVal
           ControlSource: Country
           Visible: No 


  17. Set the OnPrint property of the page footer as follows:
    
           =SetGlobalVar(Report) 


  18. Set the Height property of the page footer section to 0.5.


  19. Preview the report. Note that the "Continued from previous page..." label appears at the top of any page whose Country 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 prevent a section from being split across pages by setting its KeepTogether property to Yes. In the example, you may also want to set the ForceNewPage property of the Country header section to Before Section to help control the page layout.

You can also use the GrpKeepTogether property 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.


REFERENCES

For more information about creating a "Continued..." Header for a group that spans multiple pages in a Microsoft Access 2.0 report, please see the following article in the Microsoft Knowledge Base:

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

For more information about keeping sections or groups of records together, search the Help Index for "GrpKeepTogether property," "KeepTogether property - Groups," and "KeepTogether property - Sections."

Additional query words: inf

Keywords : kbdta RptSort
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: April 27, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.