Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q207642
Moderate: Requires basic macro, coding, and interoperability skills.

↑ Back to the top


Summary

You may want to display scroll bars in 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.

↑ Back to the top


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

↑ Back to the top


References

For more information about the ScrollBars property, click Microsoft Access Help on the Help menu, type ScrollBars property in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

↑ Back to the top


Keywords: KB207642, kbhowto

↑ Back to the top

Article Info
Article ID : 207642
Revision : 2
Created on : 6/29/2004
Published on : 6/29/2004
Exists online : False
Views : 342