Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ms access 如何确定列表框中是否选择了任何行_Ms Access_Listbox_Vba_Ms Access 2003 - Fatal编程技术网

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

Ms access 如何确定列表框中是否选择了任何行,ms-access,listbox,vba,ms-access-2003,Ms Access,Listbox,Vba,Ms Access 2003,我的访问表单中有一个列表框。我需要知道该列表框中的任何行是否已被用户选中。是否存在用于此目的的简单访问属性或方法?我不想在列表框中循环检查任何行的selected属性是否为true,因为我只想知道选择操作是否完成。代码 If ListBox.ListIndex = -1 then MsgBox "Nothing selected" end if 应该有帮助…列表框具有ItemsSelected属性,该属性返回对隐藏的ItemsSelected集合的只读引用。您可以询问该集合的Count属性

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

代码

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

应该有帮助…

列表框具有
ItemsSelected
属性,该属性返回对隐藏的
ItemsSelected
集合的只读引用。您可以询问该集合的
Count
属性

MsgBox Me.YourListBoxName.ItemsSelected.Count和“items selected”

这对我来说很有效……之前这两条评论都有,谢谢

If List4.ItemsSelected.Count = 0 Then
  MsgBox "Nothing selected"

因此,如果未选择任何内容,我将收到此消息

感谢您的分享。但是,如果我从列表框中选择并取消选择一个项目,它似乎不起作用。在这种情况下,listIndex增加到1。