2016-02-19 51 views
0

在Access中,我试图从列表框中提取选定的项目。从Access中的列表框中提取选定的行

我还没有使用列表框对象一段时间,但我似乎记得,你必须遍历选定的项目,然后使用List方法提取它们。

我的研究支持这一ascertation,但我相对于使用的List运行中的问题 -

Compile error: Method or data member not found

打印lstLocations.Selected(i)看到-1返回每一个选择和List显然不存在,那么如何提取选定的值?

Dim i As Integer 
For i = 0 To lstLocations.ListCount - 1 
    If lstLocations.Selected(i) Then 
     Debug.Print lstLocations.List(i) 
    End If 
Next i 

回答

1

使用每个循环来遍历所选项目。 类似

 Dim item As Variant 
     For Each item In Me.lbx_booking.ItemsSelected 
      If Not (Nz(Me.lbx_booking.Column(0, item), "") = "") Then 

      End If 
     Next item 
+0

谢谢,这是做的伎俩。 –

相关问题