show multiple listbox values in a text box

T

Trying to Finish

I have a listbox with 20 vlaues. I need to be able to choose more than one
value and then hve the chosen values show in a text box. Can this be done.
If so how?

Thanks much
 
M

Mr B

Trying to Finish,

Place the code below in the OnClick event of a command button and change the
the appropriate control and form names to the names of your form and controls:

Dim frm As Form
Dim ctl As Control
Dim varItm As Variant
Set frm = Forms!NameOfYourForm
Set ctl = frm!NameOfYourListBox
Dim strValue As String
For Each varItm In ctl.ItemsSelected
'get the value from the list box
strValue = ctl.ItemData(varItm)
ctl.Selected(varItm) = False
'write value to the text box
If varItm = 0 Then
Me.NameOfYourTextBox = strValue
Else
Me.NameOfYourTextBox = Me.NameOfYourTextBox & ", " & strValue
End If
Next varItm
 

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