Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Kendrick, Idaho, USA
    Posts
    277
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Accessing columns in a multi-select list box (Access 2000)

    Using VBA, do you have access to the columns in a multiselect list box like you do in a standard list box ? e.g. 1boxExample.column(2)
    I typically use the construct:

    For each varItem in ListBox.ItemsSelected
    var = ListBox.ItemData(varItem)

    to get to the items selected.

    If you can get to the column value, what is the proper syntax?

    Thanks.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Accessing columns in a multi-select list box (Access 2000)

    This example is from the Access 2002 VBA help for ItemsSelected. It outputs the value of each column of each selected item in a multi-select list box named Names on a form named Contacts:

    Sub AllSelectedData()
    Dim frm As Form, ctl As Control
    Dim varItm As Variant, intI As Integer

    Set frm = Forms!Contacts
    Set ctl = frm!Names
    For Each varItm In ctl.ItemsSelected
    For intI = 0 To ctl.ColumnCount - 1
    Debug.Print ctl.Column(intI, varItm)
    Next intI
    Debug.Print
    Next varItm
    End Sub

    The crucial expression is ctl.Column(intI, varItm). As you can see, the Column property actually has two arguments: column and row; both are 0-based. In the example at the beginning of your post, the row argument is omitted. In the example from the online help, both arguments are used.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Kendrick, Idaho, USA
    Posts
    277
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Accessing columns in a multi-select list box (Access 2000)

    That's the piece I needed. Thanks so much. (Must admit I have a horrible time with MSHelp!)

Posting Permissions

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