Listbox click event

M

mscertified

In a multi-select (simple) listbox, how do I get the row selected, and how do
I know if it's an initial select or a re-select (i.e. clicking on an already
selected item this unselecting it?) Thanks.
 
S

Stuart McCall

mscertified said:
In a multi-select (simple) listbox, how do I get the row selected, and how
do
I know if it's an initial select or a re-select (i.e. clicking on an
already
selected item this unselecting it?) Thanks.

Some untested air code:

Dim itm As Long

With Me.List0
For Each itm In .ItemsSelected
If itm = .ListIndex Then
Debug.Print .ItemData(.ListIndex) & " selected"
Else
Debug.Print .ItemData(.ListIndex) & " de-selected"
End If
Next
End With

This isn't a perfect solution, but if you take careful note of what's
happening in the debug window as you click around, you'll see that it's
workable.
 
D

Douglas J. Steele

I don't believe there's any way, other than keeping track of all of the
selected rows yourself.
 
S

Stuart McCall

Stuart McCall said:
Some untested air code:

Dim itm As Long

With Me.List0
For Each itm In .ItemsSelected
If itm = .ListIndex Then
Debug.Print .ItemData(.ListIndex) & " selected"
Else
Debug.Print .ItemData(.ListIndex) & " de-selected"
End If
Next
End With

This isn't a perfect solution, but if you take careful note of what's
happening in the debug window as you click around, you'll see that it's
workable.

Correction:

Dim itm As Variant
 
D

Dale Fye

The following worked for me. I created a multi-select (simple) listbox, and
added two textboxes to a form. Then used the following to identify the value
in the bound column of the most recently selected item in the listbox, and to
also determine whether it was selected

Private sub lst_Attributes_Click

Me.txt_Last_Item_Clicked = Me.lst_Attributes.Column(0)
Me.txt_IsSelected =
Me.lst_Attributes.Selected(Me.lst_Attributes.ListIndex)

end sub

HTH
Dale
 

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