Hi,
Issue:
I have two list boxes on a form.
I want to copy items that are selected from the first one (MListSource) to the second one (MListFinal).
Problem
I am able to only copy the value from the "Bound" clomun of my first list box, but my list boxes have two columns "ID" and "Name" and I need to copy an array to the other list box.
Do you know how?
Here is the code to copy the bound column:
----------------------------------------------------
Dim MListSource As ListBox, MListFinal As ListBox
Dim itm As Variant
Set MListSource = Me!MListSource
Set MListFinal = Me!MListFinal
' Check selected items.
For Each itm In MListSource.ItemsSelected
' Set RowSource property for first selected item.
If MListFinal.RowSource = "" Then
MListFinal.RowSource = MListSource.ItemData(itm)
Else
' Check whether item has already been copied.
If Not InStr(MListFinal.RowSource, MListSource.ItemData(itm)) > 0 Then
MListFinal.RowSource = MListFinal.RowSource & ";" & MListSource.ItemData(itm)
End If
End If
Next itm
Issue:
I have two list boxes on a form.
I want to copy items that are selected from the first one (MListSource) to the second one (MListFinal).
Problem
I am able to only copy the value from the "Bound" clomun of my first list box, but my list boxes have two columns "ID" and "Name" and I need to copy an array to the other list box.
Do you know how?
Here is the code to copy the bound column:
----------------------------------------------------
Dim MListSource As ListBox, MListFinal As ListBox
Dim itm As Variant
Set MListSource = Me!MListSource
Set MListFinal = Me!MListFinal
' Check selected items.
For Each itm In MListSource.ItemsSelected
' Set RowSource property for first selected item.
If MListFinal.RowSource = "" Then
MListFinal.RowSource = MListSource.ItemData(itm)
Else
' Check whether item has already been copied.
If Not InStr(MListFinal.RowSource, MListSource.ItemData(itm)) > 0 Then
MListFinal.RowSource = MListFinal.RowSource & ";" & MListSource.ItemData(itm)
End If
End If
Next itm