Help with a listbox

  • Thread starter Thread starter EAB1977
  • Start date Start date
E

EAB1977

I have a listbox that has the multiselect property set to none. I want
to select a item in a listbox to display some information to the user
based on the selection he/she made. How do I do this? The below code
seems to not work.

Dim lst as Listbox

Set lst = Me.lstPlant
For intCurrentRow = 0 To lst.ListCount - 1
If lst.Selected(intCurrentRow) Then
Me.numStandardsCreated.Value = lst.Column(2,
intCurrentRow)
End If
Exit For
Next intCurrentRow
 
EAB1977 said:
I have a listbox that has the multiselect property set to none. I want
to select a item in a listbox to display some information to the user
based on the selection he/she made. How do I do this? The below code
seems to not work.

Dim lst as Listbox

Set lst = Me.lstPlant
For intCurrentRow = 0 To lst.ListCount - 1
If lst.Selected(intCurrentRow) Then
Me.numStandardsCreated.Value = lst.Column(2,
intCurrentRow)
End If
Exit For
Next intCurrentRow


That's not how the Selected property works. Rather than go
into that, here's a simpler (one line of code) way to do
what you want:

Me.numStandardsCreated = lst.Column(2)
 
Back
Top