Combo box Sorting

AmyGotz

New member
Local time
Today, 00:41
Joined
Nov 7, 2003
Messages
6
Is there a way to sort a combo box other than Ascending or Descending order? I have a combo box on my form that I would like to sort in an intuitive order (the most selected option first and so forth) but I'm not sure if this is possible!

Thanks in advance for any replies!!
 
This is possible. You'll need some way of keeping track each time a choice is made from the combo box, most likely a separate table. You'll need to run a query that gets a count of how many times an time has been chosen. Then you'll need to join that query to the list of items that feeds the combo box. Finally, base the combo box rowsource on that query (with the list of items and the number of times they've been previously selected) and sort on it.
 
I guess I didn't make myself clear. I already know the order that I want the combo box to appear in. The combo box is being populated from a small table with only 4 values. Instead of having the items in alphabetic order I want to put the items in a different order. I don't know how to use a query to do this.
 
Well, OK, then. If the combo box rowsource is a query and you want to sort on a field, then you can set the sorting right in the query design grid. If, on the other hand, you want to set up your own custom sort order, and you only have a four values, then you can add a field to your original table or create a table of weightings for your various different values, add that table to the query, join the table to your existing query and sort on the weighting field.

For example, if you have:
Apple
Banana
Orange
Pear

and you'd like it sorted as:
Apple
Pear
Orange
Banana

Create a table that has these records:
Code:
Apple    1
Banana   4
Orange   3
Pear     2

Add the table to your existing query, join it to your query, then sort on the weightings field.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom