I Need Help List Box Selections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top