Transfer items from one listbox to another

G

Gaetan

Hi,

I'm having a little problem figuring out the code necessary to transfer
items from one listbox to another.

Listbox 1: lstUnresolved
Listbox 2: lstToComplete

Listboxes are both multi-select. lstUnresolved has 5 columns. Only the 5th
column is showing. I need to transfer all columns to lstToComplete so that I
can later transfer 2 of these columns to a table (which should not be a
problem) or switch back to lstUnresolved.

Anyone can help me out?

Thanks in advance!
 
J

Jeff Boyce

The generic approach you'll use is something like:

1 - cycle through all items in Listbox1
2 - if an item is selected (see .ItemSelected), use an Append/Insert to
"move" it to the table that underlies Listbox2
3 - if you don't want to (continue to) see the selected items in
Listbox1, requery it (and make the query exclude those found in 2)
4 - if you DO want to see the selected items you've moved to Listbox2,
requery it
5 - if you are moving from Listbox2 to Listbox1, use a Delete query to
remove the item from the table under Listbox2
6 - (you may have to use the cycle-through-items approach)
7 - remember to requery to see the change

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Gaetan

Alright... I'll try this, but can you give me a hint as to what the code
would be to transfer the items from a list box to the other one considering
there's 5 columns of data?

BTW, listbox2 is unbound.

Thanks.
 
J

Jeff Boyce

Ah, but you aren't transferring the 5 columns of data, just the PrimaryKey
of the record(s) you want to see in the second listbox.

If Access were a spreadsheet (it isn't, you know), you'd probably copy all
5, but in a relational database, you only need to know where to look (i.e.,
the rowID).

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
J

Jeff Boyce

Do an on-line search on "ms access paired listboxes" (without the quotes).

You should see thousands of references to ways to do this.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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