Previous and next item in a combobox???

Nirious

Registered User.
Local time
Today, 05:10
Joined
Jul 31, 2004
Messages
106
I have a combobox which contains numeric values ordered descending.
After the combo gets updated some stuff gets loaded on the form.
I want to have two buttons "previous" and "next" that give me the listitem 1 lower and 1 higher than the current one.

I used dlookup to get the higher value, but that doesn't work for the lower number so I'm stuck.

there must be a better way....
 
This is the piece of code I have right now

It works fine 1 time and than I get ListIndex=-1 which gives me the first item in the list :(

Code:
If Not Combo34.ListCount <= 0 Then
Combo34.SetFocus
If Combo34.ListIndex < Combo34.ListCount - 1 Then
    Combo34.Value = Combo34.Column(0, Combo34.ListIndex + 1)
Else
    Exit Sub
End If
Beginsituatie
Sync_Alles
End If
 
After some messing around

Yeah, had a good night sleep (that really helps) and found my answer :p

Code:
Dim rs As Object

Set rs = Combo34.Recordset.Clone
rs.FindFirst "[bestelbonnr] = " & str(Me![Combo34])
rs.MoveNext
If rs.EOF Then
    Set rs = Nothing
    Exit Sub
End If
Combo34.Value = rs!bestelbonnr
Set rs = Nothing

Beginsituatie
Sync_Alles
 

Users who are viewing this thread

Back
Top Bottom