Hello all. I am having some problems in moving data from one list box to another.
I have attached the database below.
Form 1 contains two listboxes, labelled Left and Right. My objective is to select multiple records from left listbox and move them to the right listbox. I can successfully transfer single records but when I select multiple records and press the button (">") to move them, all the selected records get copied but only the last selected record in the left listbox gets deleted.
The code I used is as below. lstDataLS and lstDataRS are left and right listboxes respectively. The code runs after pressing a button.
Can anyone help me to find out what am I doing incorrectly.
Thanks.
I have attached the database below.
Form 1 contains two listboxes, labelled Left and Right. My objective is to select multiple records from left listbox and move them to the right listbox. I can successfully transfer single records but when I select multiple records and press the button (">") to move them, all the selected records get copied but only the last selected record in the left listbox gets deleted.
The code I used is as below. lstDataLS and lstDataRS are left and right listboxes respectively. The code runs after pressing a button.
Code:
Dim Msg As String
Dim i, j As Variant
Dim a As Long
If Me.lstDataLS.ListIndex = -1 Then
Msg = "Nothing"
Else
For Each i In Me.lstDataLS.ItemsSelected
Msg = "" & Me.lstDataLS.Column(0, i)
Me.lstDataRS.AddItem (Msg)
Next i
End If
Do While lstDataLS.ListIndex <> -1
Me.lstDataLS.RemoveItem (Me.lstDataLS.ListIndex)
Loop
Can anyone help me to find out what am I doing incorrectly.
Thanks.