List Box

S

SH

How can you select Multiple items in a list box e.g. by
holding down Ctrl and selecting more than 1 item on a form
and store all the items you have selected in the relating
table?

Any help would be great.
 
M

Michel Walsh

Hi,


To save each selected items in a multiple selection listbox, you can
walk through the ItemsSelected collection and issue an INSERT INTO for each
one.

Dim varItem As Variant
Dim db As Database : Set db=CurrentDb

For Each varItem In Me.ctlName.ItemsSelected
db.Excute "INSERT INTO myTable(fieldName) VALUES(" & _
Me.ctlName.ItemData(varItem) & ")"
Next varItem


You will need to add the right delimiters if the value is a string, or a
date; here, I assumed it is a number (and that your locale setting use a dot
for the decimal delimiter, not a coma, which may be important if the number
has a decimal portion). ctlName is the list box name. You also have to
replace MyTable and fieldName with the real name involved in your
application.


Hoping it may help,
Vanderghast, Access MVP
 
B

Bart

Try holding the shift key down and using the down arrow
key or holding the shift button down and clicking on each
item in your list. I have a form that this works on but I
also have the row source type as a "Value list" and multi
select as "Simple" in the form properties. Good luck.
 
J

John C.

See the following articles:

How to Retrieve Selected Values from a Multiple Selection
List Box in a Data Access Page
http://support.microsoft.com/default.aspx?scid=kb;en-
us;225098&Product=acc2000


How to Retrieve the Selected Items in a Multiple Selection
List Box as a Comma-Delimited String
http://support.microsoft.com/default.aspx?scid=kb;en-
us;827423&Product=acc2000


Requery Extended Multi-Select List Box Clears Selections
http://support.microsoft.com/default.aspx?scid=kb;en-
us;208525&Product=acc2000


MultiSelect Property Works Differently Than Expected
http://support.microsoft.com/default.aspx?scid=kb;en-
us;208796&Product=acc2000
 
G

Guest

-----Original Message-----
How can you select Multiple items in a list box e.g. by
holding down Ctrl and selecting more than 1 item on a form
and store all the items you have selected in the relating
table?

Any help would be great.
.

Just set the ListBox's Multi Select option to Simple or
Extended. You'll find the property on the 'Other' tab on
the properties.


Damien
 
B

Brian

Set the ListBox MultiSelect property to Extended and open
the form containing the ListBox with Window Mode set to
acDialog. This works great for true multi-select.
 

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