ACC2: Group KeepTogether Does Not Apply to Multi-Column Reports (125234)



The information in this article applies to:

  • Microsoft Access 2.0

This article was previously published under Q125234
Moderate: Requires basic macro, coding, and interoperability skills.

SYMPTOMS

The group KeepTogether property does not apply to multiple-column reports as the "Creating Snaking Columns on a Report" online Help topic suggests. The Help topic states, in part:
   To keep the first detail record with the group header, in the Sorting
   And Grouping box, set the KeepTogether Property--Groups for the group
   header to With First Detail.
				

This statement is incorrect.

CAUSE

In a multiple-column report, the group KeepTogether property applies to the entire page, not to the individual columns.

RESOLUTION

To avoid an abandoned group header at the bottom of a column, or to prevent a group header from being printed beyond a certain position on the page, use the following sample procedure as the event procedure for the group header's OnPrint property. Modify the expression "(5 * 1440)" in the procedure with the value beyond which you do not want a group header to be printed. Note that the expression "(5 * 1440)" equates to 5 inches, because there are 1440 twips in an inch. The sample procedure tests the report's Top property (the position where the report will be printed) and if the condition is true, causes the report not to be printed at that position but instead moves down the page until the condition is false, which occurs at the top of the next page. By default, the report's NextRecord and PrintSection properties are set to True after each attempt to print a section.
   Sub GroupHeader3_Print (Cancel As Integer, PrintCount As Integer)

   If Me.Top > (5 * 1440) Then
      Me.NextRecord = False
      Me.PrintSection = False
   End If

   End Sub
				

Note that this procedure works well if the Item Layout option in the Print Setup dialog box for the columns is set to Vertical. If the Item Layout option is set to Horizontal, you may want to set the NewRowOrCol property for the group header section to Before & After.

STATUS

Microsoft Access version 7.0 includes a new report GrpKeepTogether property that specifies whether groups that have their KeepTogether property set to 'With First Detail' or 'Whole Group' will be kept together by page or column.

MORE INFORMATION

Steps to Reproduce Behavior


  1. Open the sample database NWIND.MDB, and then open the Customer Mailing Labels report in Design view.
  2. From the View menu, choose Sorting And Grouping. In the Sorting And Grouping dialog box, set the Country field's GroupHeader property to Yes. Close the Sorting And Grouping dialog box.
  3. Add a text box with the following properties to the Country group header section:
          ControlSource: Country
          FontSize: 12
          FontWeight: Bold
    						
  4. Preview the report. Choose OK in the Country Filter dialog box. Note that the group header for Canada is printed at the bottom of the first column.
  5. From the File menu, choose Print Setup. Choose the More button and then in the Item Layout box choose the Vertical option button. Preview the report and note that the UK group header is printed at the bottom of the column on page 4.
To prevent abandoned group headers in this multiple-column report, use the sample procedure described above in the Country group header's OnPrint property.

REFERENCES

For more information about the GrpKeepTogther Property, search for "GrpKeepTogether Property" using the Microsoft Access for Windows 95 Help Index.

Modification Type:MajorLast Reviewed:7/5/2002
Keywords:kbusage KB125234