Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying multiple selections from a ListBox

Status
Not open for further replies.

Cohen227

MIS
Oct 30, 2001
8
US
I am wondering what the code would look like (and where I would put it) to diplay multiple selections from a ListBox into a text box. I know it will require a loop but I am not exactly sure what the format should be like. Ihope someone can help!!!

THANKS!

I currently have it set up so that one selection from the ListBox is displayed into the text box...
 
The listbox must be set to multiselect. Then you must iterate through the ItemSelected to get the values to plug into your unbound control:

...
Dim varItem As Variant
dim txtTemp As String
For Each varItem in Me.ListBox.ItemsSelected
txtTemp = txtTemp & Me.ListBox.Column(ColumnNumber) & ", "
Next
txtTemp = Left(txtTemp, Len(txtTemp) - 2)
Me.TextBox = txtTemp
...

Where ColumnNumber is the column in the listbox that you want to display beginning with 0.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top