Scrollbar position

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form containing a subform. The subform contains a horizontal
scrollbar. When the user clicks on a command button, the subform requeries.
Unfortunately the scroll bar remains in its current position. Is there code
that will automatically move the scroll bar back to the far left corner in
order to display the left portion of the subform?

Thanks,
Matt
 
You could add a line after the requery that sets the focus to the control on
the far-left side of your subform.
 
I have a form containing a subform. The subform contains a horizontal
scrollbar. When the user clicks on a command button, the subform requeries.
Unfortunately the scroll bar remains in its current position. Is there code
that will automatically move the scroll bar back to the far left corner in
order to display the left portion of the subform?

Thanks,
Matt

I use an api:
Note: I do it 10 times because one time is moving a Form.insidewidth.
If the Form is large and the visible part is small it can take up to
10 times.

Private Declare Function apiSendMessage Lib "user32" Alias
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam
As Long, lParam As Any) As Long
Private Const WM_HSCROLL = &H114
Private Const SB_PAGELEFT = 2


Public Sub ScrollToLeft(hWnd As Long)
Dim I As Long
For I = 0 To 9
apiSendMessage hWnd, WM_HSCROLL, SB_PAGELEFT, 0&
Next I
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top