Moving items from one list box to another

nosferatu26

Registered User.
Local time
Today, 06:27
Joined
Jul 13, 2015
Messages
57
Hello, I have a form where there are 2 list boxes: Part_List and acbPartList. acbPartList has multiselect enabled and what I want to do is be able to select multipler records in that list box and then press a button to add those selected records into the other list box. Here is my code for my button:

Private Sub addItemButton_Click()
Dim varItem As Variant

With Me.acbPartList_Existing
For Each varItem In .ItemsSelected
Me.Part_List.AddItem (varItem)
Next
End With

Me.Part_List.Requery
Me.Refresh
End Sub

I'm not sure if passing varItem is correct, but regardless, it isn't working because Part_List is based off of a query, its not a value list. If anyone can help me out with this I would be very grateful. If I left out information please let me know.
 
Hello, I have a form where there are 2 list boxes: Part_List and acbPartList. acbPartList has multiselect enabled and what I want to do is be able to select multipler records in that list box and then press a button to add those selected records into the other list box. Here is my code for my button:

Private Sub addItemButton_Click()
Dim varItem As Variant

With Me.acbPartList_Existing
For Each varItem In .ItemsSelected
Me.Part_List.AddItem (varItem)
Next
End With

Me.Part_List.Requery
Me.Refresh
End Sub

I'm not sure if passing varItem is correct, but regardless, it isn't working because Part_List is based off of a query, its not a value list. If anyone can help me out with this I would be very grateful. If I left out information please let me know.




This http://www.access-programmers.co.uk/forums/showthread.php?t=258405 might help
 
Thank you guys for the replies. I am having trouble implementing code from both resources though. I think my form would behave a little differently than those. The two listboxes contain different data based on the ACB. the first listbox is filtered based on the selected acb in the main form while the second listbox is filtered based off of an unrelated ACB combo box selection for comparison purposes. I am confused as to how the query will look in order to add the data from the second listbox to the first. Each field in the list box is from a different table.
 

Users who are viewing this thread

Back
Top Bottom