I use a public function which I assign to a variable
Just use a different variable for each listbox.
x = getLbx(me.MyListbox)
Code:
Public Function getLBX(lbx As ListBox, Optional intColumn As Variant = 0, Optional Seperator As String = ",", _
Optional delim As Variant = Null) As String
'Iterates thru the multiselect listbox and constructs an array of the selected items
'Arguments:
'Lbx is Listbox Object ie.Me.MyListbox
'intColumn is the column # to be returned
'Seperator is the character seperating items in array returned
'Delim is optional delimiter to be return in array ie. #1/1/2001#,#12/25/2015#
Dim strlist As String
Dim varSelected As Variant
'On Error GoTo getLBX_Error
If lbx.ItemsSelected.Count = 0 Then
'MsgBox "Nothing selected"
Else
For Each varSelected In lbx.ItemsSelected
If Nz(lbx.Column(intColumn, (varSelected)), "") <> "" Then
strlist = strlist & delim & lbx.Column(intColumn, (varSelected)) & delim & Seperator
Else
strlist = strlist
End If
Next varSelected
If Nz(strlist, "") <> "" Then
strlist = Left$(strlist, Len(strlist) - 1) 'remove trailing comma
End If
End If
getLBX = strlist
On Error GoTo 0
Exit Function
getLBX_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure getLBX of Module modLBX"
End Function