I have a textbox on a form named txtSortBySelection . Also on the form is a listbox named listSortBy.
When I click on a selection in the listbox I want that selection to appear in the textbox. But when I click on another selection in the listbox I want the 1st selection to remain in the textbox but follow it with a comma and then a space and then the 2nd selection from the listbox. In other words the listbox will display the selections from the listbox separated by a comma and a space in the order they were selected in the listbox.
I have this code but it isn't doing the job...
Private Sub listSortBy_AfterUpdate()
If .Selected(.ListIndex) = True Then
If listSortBy = "" Then
listSortBy = .Column(0, .ListIndex)
listSortBy = listSortBy & "," & .Column(0, .ListIndex)
If InStr(listSortBy, ",") > 0 Then
If InStr(listSortBy, .Column(0, .ListIndex)) = 1 Then
listSortBy = Replace(listSortBy, .Column(0, .ListIndex) & ",", "")
listSortBy = Replace(listSortBy, "," & .Column(0, .ListIndex), "")
listSortBy = ""
Me.txtSortBySelection = listSortBy