Transfer selected ListBox items to TextBox

  • Thread starter MOGSY via AccessMonster.com
  • Start date
M

MOGSY via AccessMonster.com

How can I get selected items from a MultiSelect ListBox to appear in a
TextBox on a form? (preferably displayed stacked)


Thanks!
 
D

Douglas J. Steele

What do you mean by "stacked"? Assuming you mean that you want each selected
entry to appear on a different row, try something like:

Dim strSelected As String
Dim varSelected As Variant

If Me!MyListbox.ItemsSelected.Count > 0 Then
For Each varSelected In Me!MyListbox.ItemsSelected
strSelected = strSelected & Me!MyListbox.ItemData(varSelected) &
vbCrLf
Next varSelected
strSelected = Left$(strSelected, Len(strSelected) - 2)
End If

Me!MyTextbox = strSelected
 
M

MOGSY via AccessMonster.com

Thank you! Works beautifully!
What do you mean by "stacked"? Assuming you mean that you want each selected
entry to appear on a different row, try something like:

Dim strSelected As String
Dim varSelected As Variant

If Me!MyListbox.ItemsSelected.Count > 0 Then
For Each varSelected In Me!MyListbox.ItemsSelected
strSelected = strSelected & Me!MyListbox.ItemData(varSelected) &
vbCrLf
Next varSelected
strSelected = Left$(strSelected, Len(strSelected) - 2)
End If

Me!MyTextbox = strSelected
 

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