Results 1 to 5 of 5
  1. #1
    RMittelman is offline Advanced
    Windows 10 Access 2016
    Join Date
    Dec 2010
    Location
    Simi Valley, CA
    Posts
    211

    Scroll a Subform when Another Subform is Scrolled?

    I have an Access form whose purpose is to import data changes into a table.



    Data changes are stored in a table called MemberEdits, which basically has the same columns as my Members table. MemberEdits is populated by importing data from an Excel worksheet containing those changes.

    My main form has 2 subforms called MemberEditsSubform and MembersSubform. Both are continuous forms (not datasheet), and are identical to each other. Both forms contain too many fields to display, so they both have horizontal scrollbars.

    When the user scrolls either of these subforms horizontally, I want the other subform to scroll to the same position.

    I'm familiar with using the Windows API's, and I *think* I can use GetScrollInfo and SetScrollInfo API's.
    I've seen an example of GetScrollInfo which returns a scroll position, but this was for a ListBox, and used its Scroll event to trigger the code.
    I don't believe a form or subform has a Scroll event, so I don't know how to trigger the code I need. Would SendMessage help, knowing the hWnd of the form?

    Thanks...


  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    Stephen lebans has some code, might work for you
    http://www.lebans.com/customscrollbar.htm

    and there is this link
    https://stackoverflow.com/questions/...on-screen-rows

  3. #3
    RMittelman is offline Advanced
    Windows 10 Access 2016
    Join Date
    Dec 2010
    Location
    Simi Valley, CA
    Posts
    211
    Quote Originally Posted by Ajax View Post
    Stephen lebans has some code, might work for you
    http://www.lebans.com/customscrollbar.htm

    and there is this link
    https://stackoverflow.com/questions/...on-screen-rows
    Thanks for the links, Ajax. I'm not sure the second one will help, because it seems to be for syncing subform data sheet view between one subform and another. This seems to be done by finding the same record in each subform. My issue is syncing a horizontal scrollbar which belongs to a subform not in datasheet mode with another. Since I'm not trying to sync records with each other, it doesn't seem like this will solve my issue.

    What I was hoping for was some code samples of using GetScrollInfo and SetScrollInfo.

    I will check out the Lebans solution. Thanks again...

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    You are correct. Forms don't have a scroll event.

    Though by no means providing exactly what you want, perhaps you may be able to make use of some of the code from this example app where the position of one object is determined precisely by another object http://www.mendipdatasystems.co.uk/m...ols/4594549378
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    pdanes is offline Competent Performer
    Windows 10 Access 2007
    Join Date
    Sep 2019
    Posts
    208
    I use an ActiveX scrollbar control to do something like that. I have a dialog form that does some filtering of a main form. Rather than force the user to close the dialog to examine the dataset resulting from a filtering action, the scrollbar lets them scoot the dialog form to the side and use the scrollbar to scroll the recordset of the main form up and down. They can see if they got the records they wanted without having to close the dialog and re-open it each time to try different filtering criteria.

    If you put such a scrollbar on both the forms you want to keep synced, it would be easy to code them to remain matched. However, I do not know what code you would use for horizontal scrolling of a form - I use it for vertical scrolling of a recordset in continuous form view.
    Last edited by pdanes; 10-10-2021 at 09:40 AM.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-14-2017, 04:46 PM
  2. Replies: 2
    Last Post: 09-10-2015, 03:21 PM
  3. Scroll Bar position with a subform
    By pelicanbuyer in forum Forms
    Replies: 2
    Last Post: 05-22-2013, 02:46 PM
  4. Replies: 3
    Last Post: 11-05-2012, 03:50 PM
  5. Replies: 1
    Last Post: 08-06-2010, 07:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums