Microsoft KB Archive/93927

From BetaArchive Wiki
Knowledge Base


ACC: Repeating Group Name at Top of New Column or Page (1.x/2.0)

Article ID: 93927

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 Q93927

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

SUMMARY

This article describes how to create a report that prints "continued" or "Group Name continued" at the top of each new column or page when grouped information flows from one column or page to another.

MORE INFORMATION

Microsoft Access prints a single group header at the beginning of a group to identify the beginning of the group. It does not repeat the header at the top of subsequent columns or pages. However, you can use the procedure described below to force a report to repeat the group name if the records in a group span several columns or pages. This article uses the List Of Products By Category report from the sample database NWIND.MDB.

NOTE: The steps in this article are no longer necessary in Microsoft Access version 7.0. In Microsoft Access 7.0, you can use the RepeatSection property to repeat a Group Header at the top of a new column or page. For more information about the RepeatSection property search on the word "RepeatSection" using the Microsoft Access for Windows 95 Help Index.

  1. Open the sample database NWIND.MDB.
  2. Open the List Of Products By Category report in Design view.
  3. Click Code on the View menu and add the following line to the Declarations section:

    Option Explicit
    Dim MyFlag As Integer
                        
  4. Add the following code to the OnFormat event property of the page header section:

          Dim Message As String
          Dim VerMes As Long
    
          If MyFlag = True Then
             Me.scalemode = 1
             Me.FontName = "Courier"    ' Use Courier font.
             Me.FontSize = 10   ' Use point size of 24 points.
             Message = [category name] & " Continued"   ' Text to be
                                                        ' displayed.
    
             VerMes = Me.TextHeight(Message)    ' Vertical height.
    
             Me.CurrentX = 800
             Me.CurrentY = Me.section(3).height - VerMes
             Me.Print Message
    
             MyFlag = False
          End If
                        
  5. Add the following code to the OnFormat event property of the Category Name Header section:

          MyFlag = True
                        
  6. Add the following code to the OnFormat event property of the Category Name Footer section:

          MyFlag = False
                        
  7. Take the current value assigned to the Height property of the page header section and add .25 to that value. For example, if the current Height property of the page header section is .34 inches, add .25 to this value

          .34 + .25 = .59
                            

    and then set the Height property to .59 in.

  8. Save and run the report.

NOTE: This process is designed to work only when physically printing the report. In Print Preview, you will find that the continued headings appear properly when navigating forward through the previewed pages, but while navigating backward through Print Preview, the continued headings do not preview appropriately. This is by design.

For additional information about this topic, please see the following article in the Microsoft Knowledge Base:

88156 ACC: "Continued..." Header for Groups That Span Multiple Pages


REFERENCES

For more information about printing conditional page headers, please see the following article in the Microsoft Knowledge Base:

105516 ACC: How to Print a Conditional Page Header in a Report


For information about how to create multiple-page reports with snaking columns, search for "multiple-column reports," and then "Creating Snaking Columns on a Report" using the Microsoft Access Help menu.

You can find information, instructions, and examples in the Solutions sample application (SOLUTION.MDB) included with Microsoft Access version 2.0. For more information about printing a conditional page header, open the SOLUTION.MDB database, usually located in the ACCESS\SAMPAPPS directory. In the Select A Category Of Examples box, select "Control what you print on reports," and then in the Select An Example box, select "Repeat a group name at the top of a column or page."


Additional query words: multicolumn snaking-column

Keywords: kbhowto kbusage KB93927