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

List box selection

Status
Not open for further replies.

MICKI0220

IS-IT--Management
Jul 20, 2004
337
US
I have a form that uses a lisbox selection to populate a textbox. The first listbox works fine. I have added another listbox and textbox to do the same with employee name, however the code does not allow me to populate the textbox with more than one name at a time. It replaces the name I selected first with the next one I select. Here is the code for both of them. The one that works fine is the lstcompanies. The one that doesn't is lstemployees. I hope someone can help.

Private Sub lstCompanies_AfterUpdate()

Dim varItem As Variant
Dim strList As String

With lstCompanies
If .MultiSelect = 0 Then
txtSelected = .Value
Else

For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & vbCrLf
Next varItem
txtSelected = strList
End If
End With
End Sub

Private Sub lstemployees_AfterUpdate()
Dim varItem2 As Variant
Dim strList2 As String
With lstemployees
If .MultiSelect = 0 Then
Txtselectedemploy = .Value
Else

For Each varItem2 In .ItemsSelected
strList2 = strList2 & .Column(0, varItem2) & vbCrLf
Next varItem2
Txtselectedemploy = strList2
End If
End With
End Sub
 
never mind. I figured it out. It was a multiselect property I needed to set in the lstbox. Thanks anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top