Question

I have a list box in my Access form. I need to know if any of the rows in this list box has been selected by the user. Is there any simple Access property or method exists for this purpose? I do not want to loop through the listbox to check if any row's selected property is true, because I am only interested to know if a selection action is done.

Was it helpful?

Solution

A list box has the ItemsSelected property which returns a read-only reference to the hidden ItemsSelected collection. And you can ask for the Count property of that collection ...

MsgBox Me.YourListBoxName.ItemsSelected.Count & " items selected"

OTHER TIPS

The code

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

should help...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top