AccessVB: Moving scrollbar of subform using vb

Posted on 2009-04-24
Last Modified: 2013-11-27
I have 2 subforms that are exactly the same size and that look at the same table. (They are titled: "Subform1" and "Subform2")

What VB code would I use so that when I press a button, it looks at the scrollbar on "Subform1" and moves the scrollbar to the exact same location on "Subform2".
Question by:ouestque
    LVL 7

    Accepted Solution

    You want to synchronize both? I don't  know how to activate the scrollbar with code. Think this can only be done with some windows API calls. Maybe another expert has a solution for this.

    But what you can do is to Bookmark the same record in both forms. I asume that you show the same data, meaning the same count of rows, if you want to synchronize. If so, you can do it by setting the same AbsolutePosition in both forms.

    YourForm1.Recordset.AbsolutePosition = YourForm2.Recordset.AbsolutePosition

    Open in new window


    Author Comment

    Thanks Coffeeshop, this will make both subforms set to the same record, but sometimes the record will appear on the top in one subform2 and in another location in another subform1.

    i.e.( if you select record 2 in subform1, then select record 5000 in subform2, they are both focused on the same record, but subform2 is showing the selected record at the top, while subform1 is showing the record in the middle of my subform.)

    My theory is that it refreshes the record in subform 2 to the top, because the user had to scroll down to choose that record.

    Is there a way to make them both appear in the same location. (i.e. reason for adjusting scrollbar.)
    LVL 7

    Assisted Solution

    I do this by doing a requery in both forms before I set the position. But the possibilities to synchronize in a user-friendly way are very limited, I had a lot of hassle with this.

    I know a solution with API, take a look at

    its in german language, just translate with google.

    This solution sync the horizontal scrollbars, but it did not work 100% in all cases as I testet some time ago. Think its a little overhead.

    Author Comment

    Holy Moly! I took a look at the German version of the code and it is very scattered and hard to understand. It appears to work on the German guy's program. It will be tough to adapt that to my forms...

    Author Comment

    Does anyone know if this is the simplist way to achieve what I am doing?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In the previous article, Using a Critera Form to Filter Records (, the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now