Luther said:
If you only wanted to sort by a one field at a time, I'd recommend the
old, "Click on the column header to sort ascending; click again to sort
descending" approach. But for multiple fields, that really doesn't
work.
You could put combo boxes in the form header section, each combo with
its Row Source Type property set to "Field List". You could also have
an option group, or just a check box, beside each combo box for choosing
ascending vs. descending. In the AfterUpdate event of each combo box or
Ascending/Descending control, you would call a function that evaluates
all of the combos, builds an appropriate Order By string, and applies
it.
That would be the most flexible approach, I think, but it may be more
cumbersome and occupy more form "real estate" than you like. A simpler
alternative would be to pick a relatively small set of sort sequences
that you anticipate users wanting, and put a single combo box on the
form that has these specified as a value list. Then the user could pick
one, and the AfterUpdate event of the combo box would simply apply it.
You could set it up so that the bound-column values of the combo box are
the actual OrderBy strings to be applied, or you could have two columns
in the control -- a user-friendly one to be displayed, and a second one
that is the actual OrderBy string. Either way, you wouldn't have to
analyze the user's choice to build the OrderBy string on the fly.