如何确定列表框中是否选择了任何行

got*_*sth 8 ms-access listbox access-vba ms-access-2003

我的Access表单中有一个列表框.我需要知道用户是否已选择此列表框中的任何行.是否存在用于此目的的简单Access属性或方法?我不想遍历列表框来检查任何行的selected属性是否为true,因为我只想知道是否已完成选择操作.

Han*_*sUp 13

列表框具有ItemsSelected返回对隐藏ItemsSelected集合的只读引用的属性.你可以要求Count该系列的财产......

MsgBox Me.YourListBoxName.ItemsSelected.Count & " items selected"
Run Code Online (Sandbox Code Playgroud)


Com*_*Guy 5

代码

If ListBox.ListIndex = -1 then
  MsgBox "Nothing selected"
end if
Run Code Online (Sandbox Code Playgroud)

应该帮忙......