Name

form.Scroll([ActionX] [, ActionY])

Synopsis

Scrolls the form or frame one line or page at a time.

Argument

Settings

ActionX

An fmScrollAction constant indicating how much to scroll horizontally

ActionY

An fmScrollAction constant indicating how much to scroll horizontally

ActionX and ActionY can be one of these settings:

fmScrollActionNoChange (default)

fmScrollActionLineUp

fmScrollActionLineDown

fmScrollActionPageUp

fmScrollActionPageDown

fmScrollActionBegin

fmScrollActionEnd

The following code implements navigation buttons on a frame named fNav at the top of a form. The command buttons scroll the form, and the UserForm_Scroll event moves the frame to keep it visible as the form scrolls:

 ' Requires a frame (fNav) containing four command buttons. Private Sub cmdHome_Click( ) Me.Scroll fmScrollActionBegin, fmScrollActionBegin End Sub   Private Sub cmdEnd_Click( ) Me.Scroll fmScrollActionEnd, fmScrollActionEnd End Sub   Private Sub cmdPageLeft_Click( ) Me.Scroll fmScrollActionPageDown, fmScrollActionNoChange End Sub   Private Sub cmdPageDown_Click( ) Me.Scroll fmScrollActionNoChange, fmScrollActionPageDown End Sub   Private Sub UserForm_Scroll(ByVal ActionX As MSForms.fmScrollAction, _ ByVal ActionY As MSForms.fmScrollAction, _ ByVal RequestDx As Single, ByVal RequestDy As Single, _ ByVal ActualDx As MSForms.ReturnSingle, _ ByVal ActualDy As MSForms.ReturnSingle) ' Move frame to keep buttons visible as form is scrolled. fNav.Left = fNav.Left + ActualDx ...

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.