Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scoll a form w/o scrollbar

Status
Not open for further replies.

jrobin5881

Technical User
Mar 10, 2004
228
US
I have another Userform question. I have coding so that scroll bars appear and work fine on the right side of my form so that my users can scroll up and down by clicking and dragging the bar up and down.

How can I make my form scoll as my users tab from one textbox to the next? Or if the user just clicks on the form and drags it up or down without using the scrollbar on the right? What property would I play with?
 
TabStop and tabOrder properties set TAB key behaviour. Scrolling is automatic, to keep active control visible.

As for the second topic, use Scroll event:
Code:
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)
Dim msfTestedTB As MSForms.Control, msfTargetTB As MSForms.Control, Y As Single
Y = Me.ScrollHeight
If ActionY <> fmScrollActionFocusRequest Then
    For Each msfTestedTB In Me.Controls
        If TypeOf msfTestedTB Is MSForms.TextBox Then
            If (msfTestedTB.Top < Y) And (msfTestedTB.Top > Me.ScrollTop + ActualDy) Then
                Y = msfTestedTB.Top
                Set msfTargetTB = msfTestedTB
            End If
        End If
    Next
End If
If Not msfTargetTB Is Nothing Then msfTargetTB.SetFocus
End Sub

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top