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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Selections using a List/Combo Box 1

Status
Not open for further replies.

Nilo

MIS
Jan 30, 2002
21
US
I found a response from rhicks back in Oct 2000 that solved 90% of my problem.
The first part of my dilemma was to populate a text box with what I have selected in a combo/list box.
This is what rhicks helped with:

Private Sub cmdSelectItems_Click()
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strTemp As String
Set frm = Me 'sets form to active form
Set ctl = frm!YourListBox 'Name of your listbox
For Each varItem In ctl.ItemsSelected
strTemp = strTemp & ctl.ItemData(varItem) & ", " 'adds the comma and space
Next varItem
strTemp = Left$(strTemp, Len(strTemp) - 2) 'Remove the last comma and space
Me![txtResultOfList] = strTemp
End Sub

This works fantastic for that application.
However,I want to add more selections to the existing selections already in the text box.
For example if the text box already has 1,4,7, as values I want to add 2,3,8 without wiping out 1,4,7 which is what happens.
I hope this makes sense.
Any help is good help.
And thank you rhicks , where ever you are...
 
Before your For...Next Loop set the value of strTemp to the existing value in the text box + a comma.

strTemp = Me![txtResultOfList] & ", "
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top