ACC: How to Control When Scroll Bars Are Displayed in a Subform

Last reviewed: February 20, 1998
Article ID: Q181232
The information in this article applies to:
  • Microsoft Access versions 2.0, 7.0, 97

SUMMARY

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

You may want to display scroll bars on a subform only as needed. The following function turns the scroll bars on or off according to a preset number. The scroll bars do not appear unless the number of records in the subform is greater than the preset number.

MORE INFORMATION

The following example demonstrates how to use an event procedure in the OnCurrent property of the subform to display or hide the scroll bars.

  1. Start Microsoft Access and open the sample database Northwind.mdb.

  2. Open the Quarterly Orders Subform form in Design view.

  3. Set the OnCurrent property of the subform to the following event procedure:

          Private Sub Form_Current()
    

             ' If the number of records in the subform
             ' is greater than 4, display the
             ' horizontal and vertical scrollbars.
             If Me.RecordsetClone.RecordCount > 4 Then
                Me.ScrollBars = 3
             Else
                Me.ScrollBars = 0
             End If
    
           End Sub
    
    

  4. Close the Quarterly Order Subform form and save the changes.

  5. Open the Quarterly Orders form and notice that the subform is designed to display four records at a time.

  6. Use the record selectors to scroll through the records on the main form, and note that the scrollbars appear only when needed to view additional records on the subform.

REFERENCES

For more information, search the Help Index for "ScrollBars property."


Additional query words: inf scrollbar visible hide
Keywords : FmsHowto kbdta
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Hardware : x86
Issue type : kbhowto


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: February 20, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.