Multi Select List Box to Text Box

E

Emsstop

Michelle asked a question last year (Subject: Multi Select List Box to Text
Box (put each item on separate line) 7/19/2007 1:27 PM PST ) which I want
to do - that is take the selections from a list box and concatenate them to
produce a CSV string in another field on the same form (I'm not bothered
about the separate line format bit).

Michelle's code is fine, but what do I have to call the text box and how do
I activate the update please, where do I put the code? Will it be a button
control make it all happen?

Thanks
 
A

Arvin Meyer [MVP]

Emsstop said:
Michelle asked a question last year (Subject: Multi Select List Box to
Text
Box (put each item on separate line) 7/19/2007 1:27 PM PST ) which I
want
to do - that is take the selections from a list box and concatenate them
to
produce a CSV string in another field on the same form (I'm not bothered
about the separate line format bit).

Use a listbox's click event to fill the textbox (txtSelected) with items
separated by a comma:

Dim varItem As Variant
Dim strList As String

With Me!lstElevation
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ","
Next varItem
If strList <> "" Then
strList = Left$(strList, Len(strList) - 1)
End If
Me.txtSelected = strList
End If

End With
 

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