ListBox multi selection string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Davo1976

    #1

    ListBox multi selection string

    Hi all,

    I'm trying to create a string based on the selections in a
    multi-select list box, ie - getting a result such as "a,b,c,d,e" . I
    have no problems doing this binding together the values of the first
    column of the list box (which happens to be the bound column), but
    what I need to do is the same thing but with the values of the second
    column ...I'm just not sure of how to refer to this second column to
    get this working (the end goal is to whack this string into a report
    label). I have tried a few things to get it going, but not being a
    coder I need some help.

    So how would I need to adjust the code below to refer to the second
    column of the list-box? ...or as it is not the bound column, do I have
    to approach it in a different manner?

    For Each varitem In Me.lstMyListBox .ItemsSelected
    If MyStr = "" Then
    MyStr = "'" & Me.lstMyListBox .ItemData(varit em) & "'"
    Else
    MyStr = MyStr & ", '" & Me.lstMyListBox .ItemData.Colum n(varitem)
    & "'"
    End If
    Next varitem

    Thanks all
  • Dave Perry

    #2
    Re: ListBox multi selection string

    davey8000@hotma il.com (Davo1976) wrote in message news:<f124dadc. 0405110450.7212 5159@posting.go ogle.com>...[color=blue]
    > Hi all,
    >
    > I'm trying to create a string based on the selections in a
    > multi-select list box, ie - getting a result such as "a,b,c,d,e" . I
    > have no problems doing this binding together the values of the first
    > column of the list box (which happens to be the bound column), but
    > what I need to do is the same thing but with the values of the second
    > column ...I'm just not sure of how to refer to this second column to
    > get this working (the end goal is to whack this string into a report
    > label). I have tried a few things to get it going, but not being a
    > coder I need some help.
    >
    > So how would I need to adjust the code below to refer to the second
    > column of the list-box? ...or as it is not the bound column, do I have
    > to approach it in a different manner?
    >
    > For Each varitem In Me.lstMyListBox .ItemsSelected
    > If MyStr = "" Then
    > MyStr = "'" & Me.lstMyListBox .ItemData(varit em) & "'"
    > Else
    > MyStr = MyStr & ", '" & Me.lstMyListBox .ItemData.Colum n(varitem)
    > & "'"
    > End If
    > Next varitem
    >
    > Thanks all[/color]

    You can refer to additional columns in a listbox via:

    Me.lstMyListBox .Column(nCol, nRow)
    where nCol and nRow are zero-based indexes.

    i.e. Me.lstMyListBox (3, 4) would refer to the 4th column in the 5th row.

    Comment

    Working...