0
我在访问vba中为列表框项目上下移动写代码。需要在访问中使用.List属性。但它会引发错误,说没有找到方法或成员。任何使用.List替换方法?研究这4天以上。 私人小组cmdUP_Click()访问VBA有Listbox.List方法,因为excel VBA有
Dim i As Long
Dim leaveAlone As Boolean
Dim pos As Long
Dim Temp As String
pos = 0
With Me.lbfNames
For i = 0 To .ListCount - 1
leaveAlone = False
If .Selected(i) Then
If i = pos Then
leaveAlone = True
End If
pos = pos + 1
If leaveAlone = False Then
Temp = .RowSource(i - 1)
.RowSource(i - 1) = .RowSource(i) ' before i used .List instead of rowsource
.RowSource(i) = Temp
.ListIndex = i - 1
.Selected(i) = False
.Selected(i - 1) = True
End If
End If
Next
End With
Access中的列表框有'rowSource'属性,也许你应该检查并操作它以获得你想要的。如果你的'rowSource'是一个SQL指令,那么你需要定义这些行在SQL中的排序方式。 – Barranka
请看我上面的代码,当点击按钮时向上移动选定的项目。在这种情况下,rowource属性会抛出异常,导致错误的参数错误。 – vuyy1182