Moving Scroll Bar in VB code

B

Brad

Thanks for taking the time to read my question.

I have a form with a picture of a time table on it. The
entire time table does not fit on one screen, so there is
a scroll bar on the form. Is it possible to move the
position of the scrollbar with code?

Hope the pic helps.

Brad

|------------------------| <---top of form
| = = = = = = = = = = |^| <---top of picture
| Picture here |-|
| |0| <---Scroll bar up
| Picture here |-|
| | |
| | |
| Picture here |v|
|________________________ <---bottom of form



|------------------------| <---top of form
| |^|
| | |
| Picture here | |
| |-|
| Picture Here |0| <---Scroll bar down
| |-|
| = = = = = = = = = = |v| <---bottom of Picuture
|________________________ <---bottom of form
 
N

Neil

Brad,

If you change the value of the scroll bar in your code, the scrollbar will
then move to that position (as .value is the default property you dont need
to include it in the code). I did a quick test using the Microsoft Flat
ScrollBar and name it sbTest. I then used the following code:

Private Sub Detail_Click()

' Check to see if the scrollbar value is less than 95 (I set 100 to be
the maximum)
If Me.sbTest < 95 Then
' Increment the scroll bar value by 5
Me.sbTest = Me.sbTest + 5
End If

End Sub

Every time i clicked on my form, the scrollbar moved ok.

HTH,

Neil.
 
S

Steve

Neil,

What is the Microsoft Flat ScrollBar and how did you name it?

Thanks!

Steve
 
B

Brad

Which scrollbar are you affecting? I am assuming you are
not referring to the default scrollbars that Access
automatically places on a form.

I have put a Microsoft Forms 2.0 Scrollbar on my form but
that is the first time I've done that and am not sure how
to program it. I placed it on the form, but it does
nothing.

Thanks,

Brad
 
N

Neil

Hello Brad,

Just checked and the same thing applies to this one also.

You have to program the scrollbar to move whatever it is you need to by
code. The min and max values are (hopefully) self explanitory. Small change
is the increment the value of the scroll bar will be when the user clicks on
the arrows and Large change is the increment the value of the scrollbar will
be when the user clicks inside the bar itself (if i remember my VB training
correctly :)). With this scroll bar, it appears that you should use the
scroll event to program what you want to do.

If this is an actual picture, it might be easier to use a subform and set
it's picture property to be the picture that you want. Then, Access will
handle the scroll bars. Just an idea...

HTH,

Neil.
 
N

Neil

Hello Steve,

I am using Access 2002 and I also have Visual Basic 6.0 installed on my
computer. This may mean that I have more controls to choose from than you
do. If you click on the more controls button, in the bottom right corner of
the toolbox, you will get a list of all available controls that are
installed on your machine. If you click on one of these and then click and
drag on your form to add it, you can then treat this new control like any
other of the Access controls (give it a name and change it's properties
e.t.c.)

HTH,

Neil.
 

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


Top