Moving records from one list box to another list box

Lyncroft

QPR for ever
Local time
Today, 23:33
Joined
May 18, 2002
Messages
168
Did a search but couldn't find quite the answer.

I've a very long list box which I'm using to perform a search. To help the user I thought it would be an idea for them to be able to select record(s) from one list box and move them to another and then perform the search from that list box. Any ideas how I would go about that. I guess I would also need to be able to move them out of the second list box too if they choose the wrong record.
 
There are a bunch of thread out there, but I guess they might be hard to find. This is a very recent one: Multiselect Listbox add records . Part of it discusses moving records from one listbox to another.
 
You may want to keep it simple and only allow single-select listboxes, but if you decide to use multiselect boxes, take a look at this thread: Multi Select List Box --> Query . It discusses how to get at the selected items in a multiselect list box, and then how to run a query based on them.
 
Here's an example of something I use that has multiple columns:
Code:
For Each varItm In lst1.ItemsSelected
  For intI = 0 To lst1.ColumnCount - 1
     lst2.RowSource = lst2.RowSource & """" & lst1.Column(intI, varItm) & """;"
  Next intI
Next varItm
I put quotes around anything in lst1 before assigning the row to lst2 to account for any commas or semicolons in the data. If you don't, it'll screw up the resulting rows in the new listbox.

edit: changed a 2 to a 1. messed it up while making my names generic =)
 
Last edited:

Users who are viewing this thread

Back
Top Bottom