Multi Select Listbox

fenhow

Registered User.
Local time
Today, 13:18
Joined
Jul 21, 2004
Messages
599
Hello,

Is is possible to save vaues from a multi-select listbox to a table?

so that data comes in like this;

1,2,3,4 etc...

Thanks.

Fen How
 
If you mean Multivalue fields, then only in Access 2007/10. A word of caution most agree that the benefit of this kind of field is questionable to say the least. So don't use it.

JR
 
Hello,

Is is possible to save vaues from a multi-select listbox to a table?

so that data comes in like this;

1,2,3,4 etc...

Thanks.

Fen How

Hi just wrote the code for you, hope its working:
assuming
the name of listbox is list0
the name of table is tablename
the name of fieldname is fieldname

Code:
Dim ValueToBeAdded As String
Dim varItem As Variant
ValueToBeAdded = ""
For Each varItem In Me![List0].ItemsSelected
         ValueToBeAdded = ValueToBeAdded & "," & Me![List0].Column(0, varItem)
Next varItem
ValueToBeAdded = Right(ValueToBeAdded, Len(ValueToBeAdded) - 1)
'MsgBox ValueToBeAdded
DoCmd.SetWarnings (False)
DoCmd.RunSQL "INSERT INTO [tablename] ( fieldname ) SELECT "" & ValueToBeAdded & "" "
DoCmd.SetWarnings (True)

Enjoy :D
 
Last edited:

Users who are viewing this thread

Back
Top Bottom