View Single Post
  #2  
Old June 10th, 2009, 07:13 PM posted to microsoft.public.access.forms
Douglas J. Steele[_3_]
external usenet poster
 
Posts: 3,143
Default Selection from List Box to Text Box

You can't bind a multi-select list box, so you'll have to do this via VBA.

Dim ctlLB As Control
Dim strValues As String
Dim varSelected As Variant

Set ctlLB = Me!NameOfListbox

strValues = vbNullString

If ctlLB.ItemsSelected.Count 0 Then
For Each varSelected in ctlLB.ItemsSelected
strValues = strValues & ctlLB.ItemData(varSelected) & ", "
Next varSelected
strValues = Left$(strValues, Len(strValues) - 2)
End If

strValues will now contain a comma-delimited list of all of the items
selected in the listbox.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Trini Gal" wrote in message
news
Hello,

I have a multi select list box, and I would like to have each selection
the
user selects to show up in a text box separated by commas. I have read
enough and I know that its "Evil" to store more than one piece of data in
a
field. This textbox is a notes/memo field, and is only being used as
such.
I'm thinking that this would happen in the AfterUpdate Event of the List
Box.

Does anyone have code that would help me out, or can someone point me in
the
right direction?

Thanks.