Copy from 1 list to another list

abenitez77

Registered User.
Local time
Today, 12:23
Joined
Apr 29, 2010
Messages
141
I have list1 in form1 and a user will select multiple items from that list. There is a button on form1 that when clicked, it opens form2. I want to copy All the list items from list1 to list2 on form2 and I want to select all the items that are on list1 on list2. So that list2 has the items selected just like list1. How can i do this? I am able to copy the items from list1 to list2 but having a hard time selected the items from list1 onto list2.
 
on your second form's load event:

private sub form_load
dim varSelected as variant
for each varSelected in Forms!form1!listname.ItemSelected
Me.list.AddItem Forms!form1!listname.ItemData(varSelected)
next
end sub
 
You can use the same method as Arnelgp posted to select the records.
To do that :
Code:
private sub form_load
dim varSelected as variant
for each varSelected in Forms!form1!listname.ItemSelected
Me.list.Selected(varSelected) = true
next
end sub

Didn't tested the code, but it should work.
 
Thanks, but that does not Select the items and it only loads the selected items.

I think I figured out a way. This is working for me:

I'm adding the same rowsource to the listbox2 as listbox1. Then I am Selecting same items like this below. The listbox is the same name. The first listbox is in the current form and the other is in the SubForm of MainForm. I'm running this from the current form, that's why I'm using Me.


For i = 0 To Me.lst_AuditNbr.ListCount - 1
If Me.lst_AuditNbr.Selected(i) Then _
Forms(MainForm)(SubForm).Controls("lst_AuditNbr").Selected(i) = True

Next i
 

Users who are viewing this thread

Back
Top Bottom