[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2920
  • Last Modified:

Get / Set Horizontal Scrollbar Postion in using VBA in MS Access form

I have a form where the width of the all the columns exceeds the width of the window even when it is displayed full screen. If the user uses the horizontal scroll bar to view the columns to the right of the window and then requeries the data  the scroll bar moves back so that the first column is at the left hand side of the window. The use then has to scroll back to the position where they were before the requery. Is there anyway of getting the position of the horizontal scroll bar and then after the requery resetting it back to its postion before the requery ? I have found a referent to http://www.lebans.com/setgetsb.htm but the examples are from a very old version of Access and do not seem to work with 2007 or 2010.

Thanks

John
0
jhswinson
Asked:
jhswinson
  • 2
2 Solutions
 
Rey Obrero (Capricorn1)Commented:
what is the view  of the form you are working on?

here is how i would do this..
- remember the control you are working on
-remember which record you are working on before doing a requery

after the requery,
- find the record using FindFirst
- set the focus to the control

if you can't make this work, upload a copy of your db..
0
 
Rey Obrero (Capricorn1)Commented:
0
 
Jeffrey CoachmanCommented:
>If the user uses the horizontal scroll bar to view the columns to the right of the window and then requeries the data  the scroll bar moves back so that the first column is at the left hand side of the window. The use then has to scroll back to the position where they were before the requery.>

1. Then perhaps you need to change your "tab" order, so that the fields are in a more relevant order.

2. ...or consider using a "Single Form" design where you can fit more filed into the available area without the need for scrolling.

3. Or use a "Continuous Form" and use a button to return to the previous Control Field.
(But AFAICT, this would require setting a variable on each control...)

4. The question here is; ...are these "Always" the same controls in the exact same order every time?
If so, then you can hardcode the target control/field.
Something like this on the click event of a button:

Private Sub Command8_Click()
    Me.txtOrderID.SetFocus
End Sub

This will always move the focus back to the the OrderID field/control ("txtOrderID")

JeffCoachman
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now