I am not certain why this is, but in the Click event, I need to get at the selected item in my Listbox, but when the loop is initialized, there are no selecteditems available.
Private Sub lstUPSCs_Click()
On Error GoTo Err_lstAttribute_Change
Dim strSelect As String
Dim sQuery As String
Dim sUPSC As String
Dim itm As Variant
For Each itm In Me.lstUPSCs.ItemsSelected
strSelect = strSelect & "," & LTrim(RTrim(Mid(lstUPSCs.Column(0, itm), 1, 8)))
Next
END SUB
Any help with fixing this problem please?
For a multiselect list box, the following code should return a list of values in the first column (column 0). I would not generally use a click event for a multiselect listbox.
For a listbox without multiselect, the default value of the listbox is the value of the bound column. The above code will not work, but you can simply say:
Or
Where the number is any valid column number starting from zero.
As an aside, there is no need to LTrim, RTrim – Trim covers both.