How to determine if any row in the list is selected

I have a list box in my access form. I need to know if any of the lines in this list have been selected by the user. Is there any simple Access property or method for this? I don’t want to iterate over the list to check if any property selected in the row is true, because I am only interested in knowing if the selection action has been done.

+6
source share
2 answers

In the list box, there is an ItemsSelected property that returns a read link only for the hidden ItemsSelected collection. And you can request the Count property of this collection ...

 MsgBox Me.YourListBoxName.ItemsSelected.Count & " items selected" 
+7
source

Code

 If ListBox.ListIndex = -1 then MsgBox "Nothing selected" end if 

should help ...

+5
source

All Articles