hi,
I'm looking for suggestions/help on how to do this.
I have 2 listboxes - List1 and List2.
List1 contains a set of data (loaded from a query) with 2 columns - ID and Description.
List2 will contain every item the user selects from List1 but it only shows ID's.
Here's my problem:
I would like List2 to show both ID AND Description when user chooses an item from List1.
Here's the code:
Thank you in advance.
I'm looking for suggestions/help on how to do this.
I have 2 listboxes - List1 and List2.
List1 contains a set of data (loaded from a query) with 2 columns - ID and Description.
List2 will contain every item the user selects from List1 but it only shows ID's.
Here's my problem:
I would like List2 to show both ID AND Description when user chooses an item from List1.
Here's the code:
Code:
Private Sub cmdAddItemstoList2_Click()
Dim lst1 As ListBox, lst2 As ListBox
Dim itm As Variant
'Dim tmpDescription As String
Set lst1 = Me!List1
Set lst2 = Me!List2
' Check selected items.
For Each itm In lst1.ItemsSelected
' Set RowSource property for first selected item.
If lst2.RowSource = "" Then
lst2.RowSource = lst1.ItemData(itm)
Else
' Check whether item has already been copied.
If Not InStr(lst2.RowSource, lst1.ItemData(itm)) > 0 Then
lst2.RowSource = lst2.RowSource & ";" & lst1.ItemData(itm)
End If
End If
Next itm
End Sub
Thank you in advance.