Combo box sort order

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

Guest

I have a combo box. When items are added, via form input, I want the values
listed in alphabetical order.

Can someone help me?

Thanks
 
What does "via form input" mean: are you adding records to a table that
serves as the RowSource for the combo box, or are you using the .AddItem
method?

If you're adding records to a table, make sure that the combo box's
RowSource is based on a query that has the appropriate ORDER BY clause.

If you're adding records using .AddItem, you'll need to retrieve the
RowSource for the combo box (it'll be a semi-colon delimited list), break it
into individual elements in an array (using the Split function), sort that
array, then reset the RowSource property. If there's more than 1 column to
the combo box, this becomes much more difficult.
 
In one, I'm adding items to the value list of the combo box; i.e., cities. I
wrote a procedure for 'on not in list', so when a city is typed in that is
not in the combo list, it'll be added. But, I want that list to be in
alphabetical order. Today, I added Castlerock, but it's at the bottom of the
list. I want it at the top where it belongs.
 
I don't believe that combo boxes have a built-in "Sorted" property, so
you'll have to follow the instructions I gave for option 2 below.
 
Back
Top