Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2002
    Posts
    75

    Unanswered: Synchronize scrolling in two listboxes

    Hello All!

    I have a form with two list boxes. Both of them display data from the same table but different columns -- some of the users are used to classifying data based on entries in one column, the others - based on the other one.

    When they select data in one listbox, the corresponding entry in the other one is selected as well. When they scroll in one box, the other one needs to be scrolled as well. I managed the selection part just fine, but the scrolling turned out to be a pain.

    I found an article in the archive http://www.dbforums.com/archive/index.php/t-973824.html, but that code just doesn't work -- everything freezes and the only way to get going is to kill the active Access instance.

    If you have any ideas on how to make scrolling synchronization work, PLEASE share!

    Thanks in advance!
    Vasilyok

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    your two-list approach seems over-complicated.
    i don't offer an answer for the question as posed, but i have my own question: why not one list with a user-selected view?

    e.g. a 'selectView' combo with designview settings:
    boundcolumn 1
    columncount 2
    columnwidths 0cm; 5cm
    rowsource: value list
    1; "I prefer 'a'"; 2; "I prefer 'c'"

    store the user's preference in a one-row table
    ID=1, ListPref=2

    then some code:
    private sub selectView_AfterUpdate
    select case selectView
    case 1
    me.myList.rowsource = "SELECT a, b, x, c FROM tblBlah ORDER BY a
    case 2
    me.myList.rowsource = "SELECT c, z, a, b FROM tblBlah ORDER BY c
    case else
    msgbox "invalid selection"
    exit sub
    end select
    currentdb.execute "UPDATE nameOfOneRowTable SET ListPref = " & me.selectView & " WHERE ID = 1"
    end sub

    and in form_load() you add
    me.selectView = nz(dlookup("listPref", "nameOfOneRowTable", "ID = 1),1)
    selectView_AfterUpdate

    izy
    currently using SS 2008R2

  3. #3
    Join Date
    Apr 2002
    Posts
    75
    Thanks, Izyrider, for your response!

    I don't think that synchronization is over-complicated -- it is very user-friendly and straight-forward. In VB it works just fine. I hope to make it working in Access too...

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    if each list is sorted according to the user's preferred method (which would seem to make sense if you bother to have two lists to suit user preference, no?)

    e.g.
    Alan, Bob, Chas, Dave, Ed, Fred for those preferring firstnames
    and
    Adler, Brown, Cooper, Dealy, Engels, Frobisher for those preferring lastnames

    ?? how can you synchronise scrolling when the full names are
    Ed Adler, Chas Brown, Fred Cooper, Alan Dealey, Dave Engels, Bob Frobisher?

    synchronised selection: easy.
    synchronised scrolling: not!

    izy
    currently using SS 2008R2

  5. #5
    Join Date
    Apr 2002
    Posts
    75
    True, in your example the synchronization would not be a good approach. In our case, it is a small lookup table where all the data has been entered orderly, so sorting and displaying in correct order is not an issue.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by Brett Kaiser
    The physical order of data in a database has no meaning
    What happens if you need to insert a new value of "Chris Cringle" into your table - how do you enforce that it comes out between "Chris Connoley" and "David Dawson"?
    George
    Home | Blog

Posting Permissions

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