I'm writing code in access vba for the list box selected item to move up and down. Needs to use .List Property in access . But it throws an error says no method or member found. Any replace method with .List ?
Private Sub cmdUP_Click()
Dim i As Long
Dim leaveAlone As Boolean
Dim pos As Long
Dim Temp As Stringpos = 0
With Me.lbfNamesFor i = 0 To .ListCount - 1
leaveAlone = FalseIf .Selected(i) Then
If i = pos Then leaveAlone = True
End If
pos = pos + 1
If leaveAlone = False Then
Temp = .List (i - 1)
.List (i - 1) = .RowSource(i) ' before i used .List instead of rowsource in excel VBA
.List (i) = Temp
.ListIndex = i - 1
.Selected(i) = False
.Selected(i - 1) = True
End If
End If
Next
End With
Private Sub cmdUP_Click()
Dim i As Long
Dim leaveAlone As Boolean
Dim pos As Long
Dim Temp As Stringpos = 0
With Me.lbfNamesFor i = 0 To .ListCount - 1
leaveAlone = FalseIf .Selected(i) Then
If i = pos Then leaveAlone = True
End If
pos = pos + 1
If leaveAlone = False Then
Temp = .List (i - 1)
.List (i - 1) = .RowSource(i) ' before i used .List instead of rowsource in excel VBA
.List (i) = Temp
.ListIndex = i - 1
.Selected(i) = False
.Selected(i - 1) = True
End If
End If
Next
End With
Last edited: