Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Question Unanswered: Speed up list box scrolling

    I have an unbound list box which displays information from a table, using SQL statements, based on the option selected. Dragging the vertical scroll bar is slow to move down the list of about 1,000 items, and has to be dragged several times downward to get to the bottom of the list. After I've finally reached the bottom, scrolling works fine. If I click on the first item in the list, then press Ctrl+End and Ctrl+Home, the scrolling works as one would expect: the complete list can be scrolled in one movement of the scroll bar.

    I've tried to automate in VBA the Ctrl+End/Ctrl+Home sequence, with the focus on the list box but have not succeeded yet. I've tried SENDKEYS "^{END}" (with quotes) follwed by SENDKEYS "^{HOME}".

    Your advice will be appreciated for this Access 2000 question.

  2. #2
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511
    In my VBA code, the SENDKEYS statements were followed by a statement that moved the focus away from the list box to another control. When I kept the focus on the list box, list box scrolling worked fine. I wanted to return the focus to an option button, but for this to work I need to keep the focus on the list box.

    If anyone has insight about improving list box scrolling, in an automated way (VBA) that causes the list box to quickly scroll hundreds of items, I would like to know about it.

    I am further enlightened and I hope someone else can learn from this as well.

    The problem has been resolved, but recommendations are welcome.

  3. #3
    Join Date
    Sep 2002
    Location
    Coventry, Warwickshire, UK
    Posts
    74
    The problem is the same as when you open a large table in a datasheet. If you use the scroll bar before the table has read all the records, you will experience the same phenomenon. As soon as all the records have been read, Access apportion the scroll bar correctly so that one sweep will go from the top to the bottom of the data.

    Until your SQL has finished executing and therefore Access then knows how many records there are, it cannot apportion the scroll bar.

    Unfortunately, I don't know of a way of forcing it to the end when used with a ListBox. For a recordset, you would use rs.MoveLast, of course.
    Roger Hampson
    XI - ecs (UK) Ltd

  4. #4
    Join Date
    Apr 2003
    Posts
    3
    Try this...

    Private Sub Form_Load()
    List_Count = DCount("[RecID]", "Your_Table")
    ListBox1 = ListBox1.ItemData(List_Count - 1)
    ListBox1 = ListBox1.ItemData(0)
    End Sub

  5. #5
    Join Date
    Jan 2002
    Location
    Bay Area
    Posts
    511

    Smile

    Thanks for your solution to bring the entire contents of a listbox into memory so that one sweep of the scrollbar will scroll from top to bottom at the first scrolling.
    The one-line solution I am using provides the desired result:
    Me.myListBox.Selected(Me.myListBox.ListCount) = True

    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •