Access MVP (2010-2015)

oOo.oOo.oOo.oOo.oOo.oOo

Controlling Scrollbars in Subforms…

Subforms are a little peculiar when used as Continuous Forms… when the Subform produces 3 records which, in this example, calls for the Scrollbar and you then switch, from the Main Form, and you only have two records or less showing you have this shadow area where the Scrollbar used to be (Figure2)… slightly annoying and not very nice looking on your Form.

To avoid this put the below in the On_Current event of the Subform…

Note: In this example the Subform is sized to allow three records to show.  If you have adjusted to show more (or less) records then adjust the RecordCount accordingly.

If Me.RecordsetClone.RecordCount > 1 Then
   Me.ScrollBars = 2
Else
   Me.ScrollBars = 0
End If

Form.ScrollBars Property

Setting Visual Basic Description
Neither (forms) None (text boxes) 0 (Default for text boxes) No scroll bars appear on the form or text box.
Horizontal Only (forms) 1 Horizontal scroll bar appears on the form. Not applicable to text boxes.
Vertical Only (forms) Vertical (text boxes) 2 Vertical scroll bar appears on the form or text box.
Both (forms) 3 (Default for forms) Vertical and horizontal scroll bars appear on the form. Not applicable to text boxes.

From: https://msdn.microsoft.com/en-us/library/office/ff834790.aspx?f=255&MSPPError=-2147217396

(Though the page says Office 2013 or later this property has been available since Access 97, so, feel free to use in earlier versions of Access.)

 1,237 total views,  1 views today

Comments are closed.