Results 1 to 5 of 5
  1. #1
    haggis999 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Southampton, UK
    Posts
    60

    Question How do you force multiselect listbox to scroll to first selected item?

    I have a multiselect listbox with more items that can be shown at one time. Is there any way to force it to scroll to the first selected item, so that it appears at the top of the visible list?

    There is a second listbox that displays the currently selected items in the multiselect listbox, but I want to make it easy to deselect the first of these in the multiselect listbox without any scrolling.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Not sure I follow. The typical way is to select from listA and then via button or double click, move selected item(s) to listB, thus listB would not need to be scrolled. Nor would you need to scroll listA to deselect; you'd do the opposite - select from listB & button click or double click items to move them back to listA. The advantage is that you can also use buttons to Move All:
    ListA >> ListB
    ListA << ListB

    or move selected from/to either list:

    ListA > ListB
    ListA < ListB
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    haggis999 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2012
    Location
    Southampton, UK
    Posts
    60
    Quote Originally Posted by Micron View Post
    Not sure I follow. The typical way is to select from listA and then via button or double click, move selected item(s) to listB, thus listB would not need to be scrolled. Nor would you need to scroll listA to deselect; you'd do the opposite - select from listB & button click or double click items to move them back to listA. The advantage is that you can also use buttons to Move All:
    ListA >> ListB
    ListA << ListB

    or move selected from/to either list:

    ListA > ListB
    ListA < ListB
    My objective for this new Access database application is to give me a way of recording keyword metadata for old family photos (negatives and slides). I started by exporting the keywords I had previously created on Adobe Lightroom for digital images. Not all of these are relevant for older images, but even after editing I will have quite a lot of keywords, which are each associated with a keyword group (e.g. PEOPLE, EVENTS, PLACES). Most of my time so far has been spent on setting up a tab control with each tab containing a multiselect listbox for one of those keyword groups. As soon as a keyword is selected via one of that tab control's listboxes it will be displayed in my AllSelectedKeywords listbox. Deselections are handled in a similar manner.

    This all works as designed, but doing deselections from that AllSelectedKeywords listbox does indeed look like a slicker solution, so many thanks for that suggestion. I will definitely give that a try.

    By moving items between the lists, as you suggest, the need to highlight selected items in my multiselect keyword lists would disappear. However, just as a matter of academic interest, I would still like to know if there is a solution to my original question.

  4. #4
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    Quote Originally Posted by haggis999 View Post
    I would still like to know if there is a solution to my original question.
    In general, you can scroll to the first selected item of a listbox using the Selected property as follows:
    Code:
        '[...]
        With Me.ListBox1
            If .ItemsSelected.Count > 0 Then
                .Selected(.ItemsSelected(0)) = True
            End If
        End With
        '[...]
    But, suggest you to follow the Micron's suggestions.
    There are several ways to filter the cascading listboxes based on their Rowsource (table/query, value list etc).

  5. #5
    haggis999 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2012
    Location
    Southampton, UK
    Posts
    60
    Quote Originally Posted by accesstos View Post
    In general, you can scroll to the first selected item of a listbox using the Selected property as follows:
    Code:
        '[...]
        With Me.ListBox1
            If .ItemsSelected.Count > 0 Then
                .Selected(.ItemsSelected(0)) = True
            End If
        End With
        '[...]
    But, suggest you to follow the Micron's suggestions.
    There are several ways to filter the cascading listboxes based on their Rowsource (table/query, value list etc).
    Thanks for that code snippet. It may prove to be useful at some time in the future.

    I have already started to change my app to follow Micron's suggestion. Having seen plenty of examples of what he described, I really should have thought of that myself, but sometimes my aging brain works a little slowly...

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

Similar Threads

  1. Replies: 15
    Last Post: 08-30-2020, 07:11 PM
  2. How to set Selected in multiselect listbox?
    By DavidFord in forum Access
    Replies: 11
    Last Post: 08-23-2019, 11:37 AM
  3. Replies: 10
    Last Post: 10-03-2018, 01:14 PM
  4. Replies: 4
    Last Post: 03-27-2018, 12:30 PM
  5. Show Checkbox when listbox item is selected
    By gammaman in forum Modules
    Replies: 5
    Last Post: 06-04-2015, 09:46 AM

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