确定单击时选择哪个访问列表框行

bd5*_*528 2 ms-access vba

在 MS Access 2016 中,是否可以确定在单击列表框时选择了哪一行。

我尝试过这样的事情

With Me.lstSector
    For lngRow = 0 To .ListCount - 1
        If .Selected(lngRow) Then
        End If
    Next lngRow
End With
Run Code Online (Sandbox Code Playgroud)

在列表框的 Click 事件上,但 Access 似乎没有注册任何行被选中

Tho*_*s G 5

您的代码有效,但前提是属性 Multiselect 为 true

对于单选列表框,只需这样做

Me.lstSector.value 'get the value
Me.lstSector.listindex ' get the index
Run Code Online (Sandbox Code Playgroud)