Help with a listbox

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
 
M

Marshall Barton

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top