How to select multiple frm drop dn list?

A

Andreea

do you know if there is a way to select multiple items
from a drop down list (like using the ctrl or shift key)
for a particular column and have them associated (stored)
with that row in the table? (verses just one item from the
list being stored for that particular column in that row)
The source type is Table/Query. Row Source is from a
column in the querried table.
 
I

Immanuel Sibero

Hi Andreea

A listbox has a property called "MultiSelect". If you set this property to
Extended, you will be able to select multiple items in that box with using
Ctrl or Shift. But this is not the end of the story. Access does not
conveniently combine or concatenate the result for you, you would have to
loop through each selected item and do something with it.

Below is an example of a form called SomeForm and a listbox within that form
called SomeListBox (aircode - just off the top of my head to give you an
example). The example goes through each selected item and simply combine
(concatenate) them.



Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim varSelectionResult as Variant

Set frm = Forms!SomeForm
Set ctl = frm!SomeListBox


For Each varItm In ctl.ItemsSelected
varSelectionResult = varSelectionResult & ctl.ItemData(varItm)
Next varItm

.... do whatever you need with varSelectionResult


That said, I have to bring up table normalization. Needing multiple values
in a column for a row suggests an unnormalized table which will create
problems. In a normalized table, you should only find ONE value at an
intersection between a column and a row.


HTH,
Immanuel Sibero
 

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