Results 1 to 3 of 3
  1. #1
    Remster is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2010
    Posts
    283

    Record selection with the vertical scrollbar on a continuous subform

    I want to share something I've discovered completely by chance that helps to answer a question I've seen asked on various forums but never seen answered. I realise I may be reinventing the wheel here.



    The question is whether it's possible to use the vertical scrollbar on a continuous form to select records, so the uppermost record is always the current record. By default, the vertical scrollbar on a continuous form scrolls through the records in a sense, but it doesn't change which record is the current record, and it doesn't change which records are visible on the screen until the first or last visible record has been passed.

    The chance discovery is that during screen painting, the form's bookmark becomes out of sync with the recordset's bookmark, because the form's bookmark changes as each row is painted. This means that when the current record leaves the first row through scrolling (.CurrentSectionTop > 0), you can sync the bookmarks (.Recordset.Bookmark = .Bookmark), and then use a well known method to calculate how many records to move through the recordset to make the uppermost record the current record (.Recordset.Move -Round(.CurrentSectionTop / .Section(acDetail).Height).

    Here's the code snippet:

    Code:
    Private Sub Detail_Paint()
    
        If Me.CurrentSectionTop > 0 Then
            Me.Recordset.Bookmark = Me.Bookmark
            Me.Recordset.Move -Round(Me.CurrentSectionTop / Me.Section(acDetail).Height)
        End If
    
    End Sub
    I've attached an example that illustrates how this might be used in a master/parent navigation form.

  2. #2
    Remster is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2010
    Posts
    283
    Minor changes to code.

  3. #3
    Remster is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2010
    Posts
    283
    Come to think of it, this bit applies only to scrolling using the arrow keys on the keyboard:

    ... and it doesn't change which records are visible on the screen until the first or last visible record has been passed.

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

Similar Threads

  1. Replies: 4
    Last Post: 01-16-2018, 02:51 AM
  2. Vertical Scrollbar Appears At Random
    By lccrews in forum Access
    Replies: 3
    Last Post: 10-31-2017, 06:54 PM
  3. Missing Vertical Scrollbar
    By JeffChr in forum Forms
    Replies: 2
    Last Post: 11-21-2014, 07:54 AM
  4. Vertical scrollbar issues with a subform
    By vange2013 in forum Forms
    Replies: 1
    Last Post: 11-27-2013, 09:13 PM
  5. Vertical scrollbar in reports
    By Cedarguy in forum Reports
    Replies: 2
    Last Post: 11-07-2012, 03:15 PM

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