Get the next or previous row in listbox

CIIIHAN

Access Padawan
Local time
Today, 15:34
Joined
Sep 16, 2011
Messages
34
Good afternoon all!

I have a DB with about 3000 records
I've made a form (Form1) where these records are seperated in 17 lists.

There are 4 dates and 4 rooms. so 16 lists and 1 list for unassigned records.
Verticaly I've got the dates 1st boxes beeing the chosen date and the other 3 beeing the next day.(showing a forcast of today and 3 coming days.)
Horizontly there are 4 rooms where they can be assinged to, B2, B3, B4, B5.(dont ask what happend to B1)

I have added a column called "Prio". Inside the lists the records are sorted using "Prio". To change the priority of certain asignments I also added 2 buttons.
One going up other going down.

I'm having a hard time making these buttons functional

I tried this using simple math
Lets say record A is selected and I click the down button.
the "Prio" of A is raised by 1 and a Dlookup searches for the record with same "Prio", lets call this one B, and lowers the "Prio" by 1.
This works great until one of the records is removed from the list(changed date or room).

A better solution for this problem is to swap the "Prio" value.
I know how to get the values of the selected record.(A)
But how can I get te values of the second record.(B)
The command .Selected(selectedItem + 1) shows the selection bar jumping but still gives the values of the first selected record.

Any help will be appriciated
Thanks in advanced!

Cihan
 
You can look at this post for ideas. I found it with google,BUT have not used it.
 
to get the second record you must test first if your are on the last item on the list:

If Me.yourList.ListIndex <> Me.yourList.ListCount - 1 Then
' show next list item value
MsgBox Me.yourList.ItemData(Me.yourList.ListIndex + 1)
End If
 
Thanks guys!
The .ItemData function did the trick.
 

Users who are viewing this thread

Back
Top Bottom