ACC: Using IsVisible Property to Show or Hide Report Controls

Last reviewed: August 29, 1997
Article ID: Q130366
The information in this article applies to:
  • Microsoft Access versions 2.0, 7.0

SUMMARY

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

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.

  1. Open the sample database Northwind.mdb (or NWIND.MDB in version 2.0).

  2. Create a blank report based on the Products table.

  3. Save the report as Report1.

  4. 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.)

  5. 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

  6. 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.

  7. 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.

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

  9. In the first Field/Expression row, select CategoryID and set the sort order to Ascending.

  10. 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
    
    

  11. 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.

REFERENCES

For more information about the HideDuplicates property, search for "How to hide duplicates in a report," and then "HideDuplicates property" using the Answer Wizard from the Microsoft Access for Windows 95 Help menu.

For more information about the Visible property, search for "Visible Property," and then "Visible Property (Application Object)" using the Microsoft Access for Windows 95 Help Index.

Keywords          : kbusage SynFnc RptLayou RptProp
Version           : 2.0 7.0
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbdocerr


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.