one list to another

spinkung

Registered User.
Local time
Today, 14:46
Joined
Dec 4, 2006
Messages
267
Hi all,

i have 2 listboxes both have 3 columns. i want to pass selected list1 values to list2.

the problem i'm having is that when i click the button to pass the values over they get added as rows instead of columns. so, if i selected row one from list1 which has 3 cols i would expect the 3 columns to appear on one row of list2. for some reason it pastes? col1 on row1 then col2 on row2 and col3 on row3.

here's what i've got.....

Code:
For Each varitm In list1.ItemsSelected
    For iLoop = 0 To list1.ColumnCount - 1
        colVal = list1.Column(iLoop, varitm)
        Me.list2.AddItem (colVal)
    Next iLoop
Next varitm

list2 is set to value list and when i look at the rowsource i see this...
value1;;;value2;;;value3

it looks like i need to build in the semi colons somewhere??

can anyone help, thanks
 
this is complicated stuff. I personally am willing to fix it for you if you will upload the database so I can see what's up with it. ;)
 
I have an Access 2007 form in which I do something similar. I have the two list boxes on the form with command buttons in between the controls with right and left pointing arrows as button graphics. Click the right pointing arrow and the selected item in the left listbox is move to the right listbox, and conversely, click the left pointing arrow and the selected item in the listbox on the right is moved to the listbox on the left. My listboxes contain two columns, but you can adapt the code for your particular needs. Here's the code for moving a selected item from one listbox to another.

Ken

Private Sub cmdAdd_Click()
On Error GoTo PROC_ERROR
Dim i As Integer
Dim strName As String
Dim strEmail As String

For i = 0 To Me.lstContacts.ListCount - 1
If Me.lstContacts.Selected(i) = True Then
strName = Me.lstContacts.Column(0, i)
strEmail = Me.lstContacts.Column(1, i)
Me.lstNewGroupMembers.AddItem (strName & ";" & strEmail)
End If
Next i

PROC_EXIT:
Exit Sub
PROC_ERROR:
Call ShowError("frmNewEmailGroup", "cmdAdd_Click", Err.Number, Err.Description, Err.Source)
Resume PROC_EXIT
Resume
End Sub
 

Users who are viewing this thread

Back
Top Bottom