By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,523 Members | 1,938 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,523 IT Pros & Developers. It's quick & easy.

Multiple select list box

P: n/a
Hi there,
I am quite a novice to MS Access, and I would deeply appreciate help on the
following:
I have created a list box in a form. I wish for that list box to enter
multiple values from table X
into table Y. Selecting the multi-select property and changing it to
advanced lets me select multiple
entries, but they are not transferred to the destination field

Could you please help?

Thank you in advance

Oren
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Usenet" <pi@actcom.co.il> wrote in message
news:bH***************@newsread1.dllstx09.us.to.ve rio.net...
Hi there,
I am quite a novice to MS Access, and I would deeply appreciate help on the following:
I have created a list box in a form. I wish for that list box to enter
multiple values from table X
into table Y. Selecting the multi-select property and changing it to
advanced lets me select multiple
entries, but they are not transferred to the destination field

Could you please help?

Thank you in advance

Oren


You will need some kind of button that carries out this action...
(once all the entries you want have been selected)
The code behind this would loop through what has been selected and insert it
into the other table.

Not really complicated....but unless you have done some coding before, you
are in for a learning curve.

Mal.
Nov 13 '05 #2

P: n/a
Please don't do this.

Storing multiple values in one field, or in multiple fields within the same
table is going to severely limit the performance, flexibility, and
queriability of your database. You need to create at related table to hold
the (potentially) many values. See:
Description of database normalization basics in Access 2000
at:
http://support.microsoft.com/?id=209534

Once you have set up the correct structure, you will want to interface it
with a subform where the user selects as many values as apply, one per row.
The subform can use a combo for selecting the value on each row.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Usenet" <pi@actcom.co.il> wrote in message
news:bH***************@newsread1.dllstx09.us.to.ve rio.net...
Hi there,
I am quite a novice to MS Access, and I would deeply appreciate help on
the
following:
I have created a list box in a form. I wish for that list box to enter
multiple values from table X
into table Y. Selecting the multi-select property and changing it to
advanced lets me select multiple
entries, but they are not transferred to the destination field

Could you please help?

Thank you in advance

Oren

Nov 13 '05 #3

P: n/a
"Mal Reeve" <lo*****@earthlink.net> wrote in message news:<kY*****************@newsread2.news.atl.earth link.net>...
"Usenet" <pi@actcom.co.il> wrote in message
news:bH***************@newsread1.dllstx09.us.to.ve rio.net...
Hi there,
I am quite a novice to MS Access, and I would deeply appreciate help on

the
following:
I have created a list box in a form. I wish for that list box to enter
multiple values from table X
into table Y. Selecting the multi-select property and changing it to
advanced lets me select multiple
entries, but they are not transferred to the destination field

Could you please help?

Thank you in advance

Oren

There's code here for walking the selected items in a Multi-select
listbox:
http://www.mvps.org/access/forms/frm0007.htm

Inside the loop, you could insert something like

db.Execute "INSERT INTO MyTable VALUES ('" & varItem "')",
dbFailOnError
so...

'******************** Code Start ************************
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim db as DAO. Database

Set db=CurrentDb
Set frm = Form!frmMyForm
Set ctl = frm!lbMultiSelectListbox

'Assuming long [EmpID] is the bound field in lb
'enumerate selected items and
'concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = "INSERT INTO Tasks (TaskDescription) VALUES '" &
ctl.ItemData(varItem) & "'"
db.Execute strSQL, dbFailOnError
Next varItem

set ctl=nothing
set frm=nothing
set db=Nothing

End Sub
'******************** Code end ************************
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.