Results 1 to 5 of 5
  1. #1
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209

    Get Values From Multi Select List Box


    I am in need of a way to get the selected items from a multi select list box in VBA. I tried this syntax, but it gives me an error of type mismatch. What is the appropriate way to capture all selected values from a multi select listbox?

    Code:
    Private Sub Command14_Click()
        Dim I As Long
        For I = 0 To lstQB.ListCount - 1
            Debug.Print lstQB.Value(I)
    	Next
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    This shows the code:

    http://www.baldyweb.com/multiselect.htm

    You can do you debug inside the loop instead of setting the strWhere variable.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Juan4412 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2010
    Posts
    209
    Quote Originally Posted by pbaldy View Post
    This shows the code:

    http://www.baldyweb.com/multiselect.htm

    You can do you debug inside the loop instead of setting the strWhere variable.
    Using the syntax you linked to it gives me numeric values not the actual selected text.

    edited text - if it makes a difference the control source for the multi-select listbox is a table that has two fields, a PK, and the value being displayed in the list box.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You need to use the Column property, like:

    ctl.Column(1, varItem)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 02-15-2016, 04:48 PM
  2. Replies: 15
    Last Post: 11-20-2013, 04:30 PM
  3. Replies: 5
    Last Post: 07-26-2012, 12:59 PM
  4. Multi select list box
    By foxtet in forum Forms
    Replies: 1
    Last Post: 05-30-2011, 02:13 PM
  5. Replies: 1
    Last Post: 10-22-2010, 10:11 AM

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