Full Version: Move Selected Items Up/Down a ListBox in Access
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
I have a sub. The second listbox contains items. I am trying to swap items to no avail.
Any assistance would be great. I found this sub on the net and trying to modify the functionally of the VBA listbox to the MS Access listbox. Apparently, the .list property is not available. I am trying to build the Rowsource incrementally.
Private Sub Command16_Click()
Dim i as Long
Dim leaveAlone as Boolean
Dim pos as Long
Dim Temp, Temp2 as String
pos = 0
For i= 0 to List2.ListCount -1
If List2.Selected(i) Then
If i = pos then
leaveAlone = True
End if
pos = pos +1
If leaveAlone = False then
Temp = List2.Item(i-1)
Temp2= List2.Item(i)
List2.RowSource= List2.RowSource & Temp2 & ";" & Temp ??not sure!!
List2.Selected(i) = False
List2.Selected(i-1) = True
End if
List2.RowSource = ???
End If
Hi CodeManiac
from your description it sounds like you want to try this..
I've attacted a DB goto the Document Tab and you will see the 2 List boxes and how to swap.
Hope this Helps
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.