Looking for way to control scroll bars with VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • simulationguy
    New Member
    • Feb 2010
    • 27

    Looking for way to control scroll bars with VBA

    I have a main form that has a tab control about 5 tabs with subforms.
    When the main form comes up the scroll bar automatically goes down a little so the tabs dont show up they are scrolled up to far. Its annoying, I would like to find some vba possibly on the open form event to lock the vertical scroll bar at the top.

    thanks
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    The problem is being caused by the Tab Order on your main form. Apparently the first control to get focus when the form opens is way down the form.

    Place a textbox on your form in the top, left most corner
    Goto Properties - Other and rename it DummyTextBox
    Now resize it down to just a pinpoint (it won't be visible on the screen)
    Now use this code
    Code:
    Private Sub Form_Load()
     DummyTextBox.SetFocus
    End Sub
    If you want to ensure that it does this when moving from record to record, place the code in the Form_Current event instead of the Form_Load event.

    Welcome to Bytes!

    Linq ;0>

    Comment

    • simulationguy
      New Member
      • Feb 2010
      • 27

      #3
      Thanks!!!

      Exactly what I was looking for and it worked perfectly.

      Comment

      Working...