Microsoft KB Archive/209981

= ACC2000: How to Hide Duplicate Group Header Information in a Report =

Article ID: 209981

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209981



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

This article applies only to a Microsoft Access database (.mdb).



SUMMARY
This article shows you how to use Visual Basic for Applications to hide duplicate information in successive group headers in a report.



MORE INFORMATION
In a sorting and grouping report, where each group header can contain information that may be duplicated from the previous group header, you can use the following code to hide duplicate information in successive group headers.

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.  Start Microsoft Access and open the sample database Northwind.mdb. Create the following new select query in Design view based on the Categories, Products, and Order Details tables:

Field: CategoryName

Table: Categories

Field: ProductName

Table: Products

Field: OrderID

Table: Order Details

Criteria: <10300

Field: Quantity

Table: Order Details

 Save the query as qryOrders, and then close it.  Create a new module. In the module Declarations section, declare a global variable called DupeHeader: Global DupeHeader as String  Save the module as basPrint, and then close it. Create a new report in Design view based on the qryOrders query.</li> On the View menu, click Sorting and Grouping.</li> In the first row of the Sorting and Grouping dialog box, select CategoryName in the Field/Expression box.</li> In the second row of the Sorting and Grouping dialog box, select ProductName, and then set the GroupHeader property to Yes.</li> Close the Sorting and Grouping dialog box.</li> On the View menu, click Field List.</li> Drag CategoryName and ProductName from the field list to the ProductName Header section of the report.</li> Drag OrderID and Quantity to the Detail section of the report.</li> If the property sheet is not visible, click Properties on the View menu.</li> Set the Height property of the Detail section to .25".</li>  Set the OnFormat property of the ProductName header to the following event procedure: Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount _      As Integer) If DupeHeader = Me![CategoryName] Then   Me![CategoryName].Visible = False Else   Me![CategoryName].Visible = True End If DupeHeader = Me![CategoryName] End Sub                    </li> Save the report as rptTest, and then close it.</li> Open the report in Print Preview and scroll through it. Any duplication of the CategoryName field in successive ProductName headers is not visible.</li></ol>

<div class="references_section">