Microsoft KB Archive/207642

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

Article ID: 207642

Article Last Modified on 6/29/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q207642



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



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.



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:  Start Microsoft Access and open the sample database Northwind.mdb. Open the Quarterly Orders Subform form in Design view.  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

 Close the Quarterly Order Subform form and save the changes. Open the Quarterly Orders form and note that the subform is designed to display four records at a time. 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.</li></ol>

<div class="references_section">