Microsoft KB Archive/130366

= ACC: Using IsVisible Property to Show or Hide Report Controls =

Article ID: 130366

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition

-



This article was previously published under Q130366



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



SUMMARY
Microsoft Access has an undocumented property named IsVisible for controls in a report. IsVisible takes a True or False value depending on whether or not the report control is being shown when its HideDuplicates property is set to Yes. By using code, you can take advantage of the IsVisible property to show or hide other controls in the report.

NOTE: The IsVisible property can be set only from the Print event of the report section that contains the control.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications" manual.

NOTE: Visual Basic for Applications (used in Microsoft Access version 7.0) is called Access Basic in version 2.0.



MORE INFORMATION
The method below demonstrates how you can use the IsVisible property to hide a line control when a text box is hidden because it contains duplicate values. By using this method, you can create a grouped report with the group header and first detail record on the same line.

 Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0). Create a blank report based on the Products table. Save the report as Report1. If it isn't already displayed, open the Default Text Box property sheet and set the AutoLabel property to No. (To open the Default Text Box property sheet, display the toolbox if it isn't already displayed, click the Text Box button in the toolbox, and then click the Properties button on the toolbar.) Add a line control to the detail section, and set the following properties for the control:

Name: ALine

Left: 0

Top: 0

Width: 4

Height: 0

 Add a text box to the detail section, and set the following properties for the control:

Name: CategoryID

ControlSource: CategoryID

HideDuplicates: Yes

Left: 0

Top: 0.1

NOTE: In version 2.0, there is a space in Category ID.</li> Add another text box to the detail section, and set the following properties for the control:

Name: ProductName

ControlSource: ProductName

Left: 1.2

Top: 0.1

NOTE: In version 2.0, there is a space in Product Name.</li> On the View menu, click on Sorting And Grouping.</li> In the first Field/Expression row, select CategoryID and set the sort order to Ascending.</li>  Set the Detail section's OnPrint property to the following event procedure: If Me![CategoryId].IsVisible Then Me![ALine].Visible = True Else Me![ALine].Visible = False End If </li> On the File menu, click Print Preview. Note that the line control is displayed only when the IsVisible property for the CategoryID control is true.</li></ol>

<div class="references_section">