I Need Help List Box Selections

C

Cynthia

I have done this before, but lost my code. I have a list box that allows
multiple selections. I need to be able to move the focus from what is
selected up one record in the list. How do I do this? i.e. if items 3 and 6
are selected, I need to change the selection to items 2 and 5.
 
P

pietlinden

Cynthia said:
I have done this before, but lost my code. I have a list box that allows
multiple selections. I need to be able to move the focus from what is
selected up one record in the list. How do I do this? i.e. if items 3 and 6
are selected, I need to change the selection to items 2 and 5.

Something like:

Private Sub Command2_Click()
Dim varItem As Variant

For Each varItem In Me.List0.ItemsSelected
MsgBox Me.List0.ItemData(varItem - 1)
Next varItem
End Sub
 
C

Cynthia

Thank you, this may get me started.
What does this line do? MsgBox Me.List0.ItemData(varItem - 1)
I am doing a for each statement and need to know what item I am on, and then
deselect it and select the one below, what statement will select and deselect?
Below is a sample of my code.

For Each varItem In Me.listCircList.ItemsSelected
ID = Me.listCircList.Column(0, varItem)
num = Me.listCircList.Column(4, varItem)
newnum = num - 1
If num = 1 Then
MsgBox "Cannot move up already at Top of List"
Else
DoCmd.RunSQL "Update EleCircRoute set routenum = " & num & "
where CircID = " & CircID & " and routenum = " & newnum & ""
DoCmd.RunSQL "Update EleCircRoute set routenum = " & newnum
& " where ID = " & ID & ""
End If
Next varItem
 
Top