"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 ************************