Results 1 to 9 of 9
  1. #1
    AccessGeek is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    19

    Maintain Selection Order in Multi Select list Box

    Hi,


    I have a select list box that allows multiple selections using code from here: http://support.microsoft.com/kb/827423.

    This is working fine, but I need to list the items in the order they were selected. It appears that this code lists them in the order of the source table. Is there a way for me to maintain the selection order?

    I have searched this forum and the Web for an answer but am coming up empty. Any help would be greatly appreciated!

    Thanks!

    Doug

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you need to save the selected items to somewhere whenever they are being selected or deselected. then you get the order.

  3. #3
    AccessGeek is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    19
    Do you know the line of code that will let me do this? Or know of an example somewhere? Thanks!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Post 4 (elaborated on a little in 7) is how I add/delete records to a temp table so I know the order in which the items were selected.

    https://www.accessforums.net/program...oxes-8172.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    AccessGeek is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    19
    Thanks for your help. I am still stuck. The attached db is a sample of where I am so far. I have a text box that concatenates my selections. This is necessary for an app I am creating that is feeding a web analytics query. These parameters are fed in a string and the selections need to be in order picked by the user. I did try capturing the selections as they occur in a table ("Selected"), but am not sure where to go now. Any suggestions? Has anyone ever tried something like this? Thanks!!!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I guess I should have clarified that the delete should only delete the item just deselected, so more like this:

    CurrentDb.Execute "Delete * From Selected WHERE Selection = '" & ctl.Column(0) & "'"

    The code you have is deleting all previous selections. I would have an autonumber field in that table so you can be sure of the order. Then instead of looping the listbox to set the textbox (which I probably wouldn't bother with, but...) you'd loop a recordset of the table sorted by the autonumber field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    AccessGeek is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    19
    Paul,
    I set it up just as you said and it's working like a charm! It's awesome to get something working that you've been stumped by....couldn't have done it without you! Thanks!

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Excellent, glad to hear it. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    AccessGeek is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2010
    Posts
    19
    Thanks! I've been a lurker for awhile and have learned a great deal from this forum. Hopefully I can help someone else at some point.
    Thanks again!

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

Similar Threads

  1. 2 multi select list boxes on one search form
    By woodey2002 in forum Forms
    Replies: 2
    Last Post: 11-05-2010, 12:44 PM
  2. Replies: 1
    Last Post: 10-22-2010, 10:11 AM
  3. Multi-select List Boxes
    By Rawb in forum Programming
    Replies: 6
    Last Post: 09-21-2010, 09:02 AM
  4. Replies: 1
    Last Post: 02-25-2009, 07:29 PM
  5. Replies: 1
    Last Post: 03-09-2006, 12:12 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