Sort by Any Field (Cursor Location)

M

mindlike

I have an unbound form with ~ 25 fields. I would like to create A-Z and Z-A
command buttons that when clicked will sort DESC/ASC based on which text or
combo box the cursor is located in. Functionality that is available on the
pre-canned forms that are bound. Coding for a filter button would be great
as well.

As always thank in advance for any help.
 
K

Klatuu

You don't need those buttons. Here is a much simpler way to do it and more
intuitive for a user. Put this code in your form's code module:

Private Function ComeToOrder()
Me.OrderBy = Screen.ActiveControl.ControlSource
Me.OrderByOn = True
End Function

Then for each control you want to be able to sort on, put this in the double
click event text box of the properties dialog:

=ComeToOrder()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top