Multi-Selected Items from one List Box to other empty List Box and text box

S

Sumit

Hi,

How can I transfer Multi-Selected Items from a master List Box (with data
filled from a field of a table) to other empty List Box so that I can know
all the selected data from the second List Box?

Also, How can I concatenate the selected data from the List Box to a text
box separating each data with a comma?
Is there a way that any particular selected data that has been concatenated
in the text box can be automatically deleted from the text box if I
de-select that particulat item from the List box too??

Any better alternative to this situation would be appreciated.
(I just wanted to display and store all different colors that have been
ordered under a particular product).

Thanx a lot,
Sumit
 
A

Allen Browne

To store the fact that the user ordered:
5 red pyjamas
2 white pyjamas
I think you would be better to use multiple records within an order.

Are you familiar with the Orders form in the Northwind sample database? It
has an Orders Subform where the items being ordered are written to the Order
Details table. If you add a "Color" field to the Order Details table, you
can achieve what you want by placing the items on different rows. This makes
it very easy to query your data, e.g. to see which colors are selling well,
and therefore which ones you should order in.

Storing the multi-select items in a concatenated text field is much more
work, and has integrity problems (e.g. if a color is deleted but still
exists in the text). If you want to do it anyway, you will need to loop
through the list box's ItemsSelected collection to build up the string, and
then write it to the text field. In the form's Current event you need to go
through the reverse process: parsing the string at the delimiter, and
marking the desired items as selected in the list box. You also need to redo
that in the form's Undo event, based on the OldValue of the concatenated
text field.
 
F

Fishiee

Hi Allen,
Thanx a lot for you reply and your time.
Yes I have worked on this program with separate linked tables etc.
But I needed a entirely different form (for specfic purpose) where I could
select the colors from a list using Multiselect.
1. When I select few colors from a list of more than 1000 colors in my Main
List, it would be very difficult for user to trace it, so I wanted to
transfer the selected colors to Secondary List and use the first list just
to let user select from entire list of colors. How do I do this?
2. Which event can I use such that I can get the color that user has
selected AND deselcted?
3. When I used the wizard to input a List Box in my form, one of the Steps
says MS Access can store the selected values in my database; and lets me
choose fields from a table which is source table for the form. If I choose
only one field from this source table, then I would not be able to store
multiple colors in a single row corresponding to a single product in the
table. I need to have a separate table but how can I choose another table to
store this from the wizard? This is the reason that I wanted to use a text
box and put the concatenated colors with delimiters.

I would be grateful if you could help me out here.
Thanx a lot
Sumit / Fishiee



----- Original Message -----
From: "Allen Browne" <[email protected]>
Newsgroups: microsoft.public.access.formscoding
Sent: Tuesday, July 15, 2003 8:12 AM
Subject: Re: Multi-Selected Items from one List Box to other empty List Box
and text box
 
A

Allen Browne

Fishee, I think you're making the mistake of allowing the interface to
dictate your data structure. Create a normalized structure, and then figure
out a good interface to go with it.

If you want to offer only a few colors from the 1000, you could use a
temporary table to hold the index of those colors, and use that as the
RowSource for the combo/list box the user chooses from.

I don't use the wizards, so I did not follow what you were talking about
there, but the crucial thing is to store the records in multiple rows. You
can't even get the quantities of each color right if you concatenate the
color values into a field: what will you do: concatenate a list of
quantities together into another text field as well?
 

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