Fill Listbox2 from Listbox1 multiselect

G

Guest

I have a listbox1 that holds 500+rows of clients. I need the end user to be
able to multiselect client names and have those names appear in listbox2 on
form. I am able to populate a textbox from listbox1, but it does not allow a
scrollbar if the end user exceeds the the size of the textbox(although there
is a vertical scrollbar property that does not seem to work-Access 2000).

Also, the Client name, the bound field in listbox1, contains commas that
have caused me some heartache building valuelists from the .ItemsSelected.
The commas act the same as the ";" delimiter causing client names to seperate
and appear on two rows.

The code I had worked with was something like;
With Listbox1
For each varItem in listbox1.ItemSelected()
me!Listbox2.addItem(me.listbox1.column(1,.itemdata(varItem))
Next varItem
End With

This caused each additional item selected to appear that many times (i.e.
1st item showed once, 2nd item showed twice,etc.)

It also did not allow for deletions if the end user selected the wrong item.

Any suggestions
 
J

Jeff Boyce

Another approach to using paired listboxes would be to not actually write
the values into a list. Instead, if you based Listbox1 on all "available"
rows/clients, and use a field in a table to indicate "selected" (yes/no),
your Listbox2 can have, as a source, only those that are marked "selected".

You'd still have to work out the code to mark "selected", and probably to
allow selection of a row in Listbox2 and get it "un-selected".

The wizard Access provides in guiding you to creating a report offers a
visual example of paired listboxes and adding/removing items from listbox2.

Good luck!

Jeff Boyce
<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