Multiselections in List Box

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

Hi,
I have a form on which there is a list box which permits
a user to select more than one item. This visually works
fine. The list pulls from one table (A) and, ideally,
would write the selections into another table (B).

My challenge seems to be that I have no idea how to
capture the multiple selections. My thought was to
concatenate these into one field on (B).

The goal was to select A1,A3,A4; then create A1+A3+A4 and
write this into B.entireselection - but....

Shouldn't this be simple?

Thanks,
Barry
 
Barry said:
Hi,
I have a form on which there is a list box which permits
a user to select more than one item. This visually works
fine. The list pulls from one table (A) and, ideally,
would write the selections into another table (B).

My challenge seems to be that I have no idea how to
capture the multiple selections. My thought was to
concatenate these into one field on (B).

The goal was to select A1,A3,A4; then create A1+A3+A4 and
write this into B.entireselection - but....

Shouldn't this be simple?

The reason it isn't simple is that it violates proper database design to
store multiple values in a single field. The only legitimate use of a
multi-select ListBox is to do something with the selections in a code
routine. What you should have is a second *related* table and then use a
subform to store the multiple selections in the second table.
 
Barry,

When you make selections in a multiselect listbox, the selections are saved in a
ItemsSelected collection. After you have made all the selections, you then need
to loop through the ItemsSelected collection and add each selection to table B
using the recordset AddNew method.

Look in the Help file for ItemsSelected and AddNew.
 
Thanks guys,
You're absolutely right - the design is flawed. I need
to rethink the whole thing. The related table is the way
to go. [Many self-flogs] violated my own design
principles!
 
Back
Top