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

Help with Multi Select List Box

Status
Not open for further replies.

patiya

MIS
Nov 24, 2003
23
US
I have a multi select list box (Row source is a table with 3 fields i.e. Unique ID, Last and First Name) and a Text box. The Users will select items from the List box and it will populate the Text Box. and Vice Versa.

I need to be able to do the following.

1. Allow users to select single item from the listbox and populate textbox.

2. Allow users to select multiple items from the listbox and populate textbox.

3. Allow users to de-select single item from the Text Box and that Item will be re-populated in the list box.

4. Allow users to de-select multiple items from the Text Box and those Items will be re-populated in the list box.

I am assuming I need 4 separarte command buttons for each of these functions.

Can anyone help with this ? I will appreciate it very much.
 
One command button should do the trick:

Dim intRecCnt as Integer
Dim strDoseTimes as String
Dim intLoop as Integer

For intLoop = 0 To lstTimes.ListCount - 1
If lstTimes.Selected(intLoop) = True Then
intRecCnt = intRecCnt + 1
If intRecCnt = 1 Then
strDoseTimes = lstTimes.Column(0, intLoop)
Else
strDoseTimes = strDoseTimes & "; " & lstTimes.Column(0, intLoop)
End If
End If
Next intLoop

txtDisplay = strDoseTimes

Put this in the On Click event of a command button; of course, change lstTimes and txtDisplay to correspond to you control names.

It will loop through the list box and concatenate the selected items into a string with each selection separated by a semicolon.

HTH


Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Guess I should have read the post more closely.

When you say 're-populate' the list box, what do you mean?

Please use the forum to continue the thread; this allows others the opportunity to contribute and, perhaps, pick up some new tips.

Larry De Laruelle
ldelaruelle@familychildrenscenter.org

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top