Combobox navigation buttons

stevekos07

Registered User.
Local time
Yesterday, 16:03
Joined
Jul 26, 2015
Messages
174
I have a combobox on a form that has many items to select from. I would like to set up navigation buttons that navigate through the combobox one item at a time.

Am I right in thinking that this needs to be based on an "apply filter" command that selects the records based on the previous or next item in the combobox? I just can't think of the best way to approach this. (Besides, I am tired and it's been a long day :D).

Cheers.
 
Why not just use a list box instead, then?

Otherwise you would need to use Me.cboComboBoxName.Column(x,y) where x is the bound column and y is the row number (both starting with 0).
 
As a follow up, if you'd rather not go with Frothingslosh suggestion have you thought about cascading combo boxes?

And by "Many Items", what kind of number are we talking about? 20's, 100's, 1000's?
 
As long as the combo box is properly sorted by the visible field, it will scroll itself as you type.

If I have a list of state names and I start typing,
C brings me to California
Co brings me to Colorado
Con brings me to Connecticut
 
I was curious if this could be done, and it can...
Code:
Private Sub cmdDown_Click()
    With Me.cbTestCombo
        If .ListIndex = .ListCount Then
            .Value = .ItemData(0)
        Else
            .Value = .ItemData(.ListIndex + 1)
        End If
        .SetFocus
        .Dropdown
    End With
End Sub
...but I wouldn't. I think AutoComplete, what Pat is talking about, is way more useful, or, I prefer to allow the user to type a few characters in a textbox, and search a list that way, for substrings. But it seems cumbersome to step one row at a time like this in a control.
hth
Mark
 
@Mark,
More interesting variant would be
Code:
Private Sub cmdDown_Click()
    With Me.cbTestCombo
        If (.ListIndex + .ListRows) >= .ListCount Then
            .Value = .ItemData(0)
        Else
            .Value = .ItemData(.ListIndex + .ListRows)
        End If
        .SetFocus
        .Dropdown
    End With
End Sub

That way you go down one page at a time instead of one item at a time.
 
Yeah, that makes is more useful, but I still wouldn't do it.
 
@Mark,

So its a better version of a bad idea? Does it hit "Optimized uselessness"?
 
Lol. Bad Idea 2.01 with new reduced uselessness. It's not a bug, it's a feature!
 

Users who are viewing this thread

Back
Top Bottom