How to scroll a MS-Access form with VBA

H

hstijnen

Hi,
I've a form in MS-Access that opens with the horizontal scroll position not
on top of the form. What can I do to make scroll position on top?

Thanks for help

Henk
 
G

Gijs Beukenoot

hstijnen gebruikte zijn klavier om te schrijven :
Hi,
I've a form in MS-Access that opens with the horizontal scroll position not
on top of the form. What can I do to make scroll position on top?

Thanks for help

Henk

Not sure, but could it have anything to do with the first element
(control) that gets the focus (having taborder 0 (zero) or,
programatically setting the focus to a control)?
 
H

hstijnen

I've a mainform which contains a tabcontrol with several tabs. On every tab
there is a subform. The form opens on the first tab. The uppermost control
has focus. This control is rather on top of the window, so that the tabs of
the tabcontrol aren't visible. And I have to scroll up to see them.
Now I'm looking for a piece of VBA to do that in the Form_Open
 
D

David C. Holley

Just a guess, but is it the scroll bar for the FORM or the ACCESS
application window. Depending on the sizing of the form, its positioning
and the Access window, you may get a horizontal scroll bar for the
window which can be confused with the one for the FORM. Its difficult
for me to provide further help since its a VISUAL thing. But try playing
with the MIN/MAX buttons on the FORM. Also, if the HEIGHT of the form is
taller than the Application window that would cause the Application
scroll bar to appear. Side question - Is the form set to display a
single record or continous records?
 
H

hstijnen

First I'm sorry, for I meant the VERTICAL scroll. It's indeed the scrollbar
of the FORM. The mainform's only function is to contain the tabcontrol with
the other subforms. The mainform has no recordselector, navigation buttons or
dividing lines.
I'm looking for some VBA code to scroll the mainform.
 
S

Stephen Lebans

For the simplest method using SendMessage see:
http://www.lebans.com/loadjpeggif.htm

and
for a more detailed solution see:

http://www.lebans.com/setgetsb.htm
SetGetSB.zip is a database containing functions to allow a user to Set
or Get the current position of a ScrollBar Thumb for a Form.

NEW - Apr. 02/2000 The current ScrollBar position is equal to the
current Record Number being displayed at the Top of the Form.

Works in Form or Datasheet view.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
H

hstijnen

Thanks, Stephen,
I've downloaded your setgetsb and tried the following code in the first
subform:

Private Sub subfrm_FG_Enter()
i = fGetScrollBarPos(Form_Mainform2) ' --> result: i = 32
i = fSetScrollBarPos(Form_Mainform2, 0) ' --> i = 0
End Sub

It seems to work, but Mainform2 continues to be scrolled, so that the tabs
were still not visible.
By the way, is my solution to arrange several forms "best practice"?
 
D

David C. Holley

Can you email me a screen print of the form?
I've a mainform which contains a tabcontrol with several tabs. On every tab
there is a subform. The form opens on the first tab. The uppermost control
has focus. This control is rather on top of the window, so that the tabs of
the tabcontrol aren't visible. And I have to scroll up to see them.
Now I'm looking for a piece of VBA to do that in the Form_Open

:
 
D

David C. Holley

What I'm getting at is that I think that theres a design issue here and
that if you find it and fix you won't need the code. Could you please
send me a SCREEN PRINT showing the form and the screen real estate
around it? (e-mail address removed)
 
D

David C. Holley

Regarding what I just posted. If you go to a doctor and ask for
something because you've got a piercing pain in your arm, the morphenine
that he gives you will take away the pain but not do anything for the
piece of steel in your arm. Being able to move the scroll bar won't
neccessarily fix the underlying problem.
 
D

David C. Holley

Based on the screen image that you sent me, it looks as if Access is
scrolling up to put the first control in the tab order at the top of the
screen. No idea as to way, since to me thats counterintuitive. Try this,
add some space above the tab control. In that space add a command button
(it doesn't have to be large, just there). Set its TRANSPARENT property
set to true. Finally change the tab order to ensure that the command
button is the first in the sequence. Make certain that the command
button is NOT a part of the tab control, just above it.
 

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

Top