Problem with click and copy from one listbox to another

K

Keith

Hello,

I have two list boxes, List27 and List29. List 27 is a multiselect.
The following code is associated with List27 and runs whenever an item is
clicked in List27.

I had hoped the following code would do the following.
When an item is clicked in List27, it is added to List 29
If the item is clicked again in List27 it is removed from List 29
What is actually happening is that items are added to List29, sometimes two
at a time, and nothing is removed.

What do you suggest?

Thank you,

Keith

code follows:

Private Sub List27_Click()

Dim ctlSource As Control

Dim a as variant
Dim b as variant
Dim c as variant

Set ctlSource = Me.List27

a = List27.ListCount

b = List27.ListIndex

MsgBox "count of items in List27 = " & a & " Listindex = " & b


c = List29.ListCount

For i = 0 To c
If ctlSource.Column(1) = List29.Column(0) Then
List29.RemoveItem (i)
Else
List29.AddItem Item:=ctlSource.Column(1)
End If
Next i


Set ctlSource = Nothing


End Sub
 
H

Hunter57

Hi Keith,

If you email me at: pw oo d57 at gm ail dot co m (email format to avoid
spam) I can send you a couple of sample DB's.

Patrick Wood
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top