DBWebApplications 





Data Manipulation  «Prev  Next»
Lesson 12 Specifying a sort order
Objective Refine your query by specifying a sort order.
When you create a query, you may find that the records come out in the order you want them. However, if they aren’t in the desired order, one option is to use the Sort buttons on the datasheet to sort them.
If you are going to use the query to create a form or report, however, or if you want to see it sorted as soon as you view the datasheet, you should specify the sort order as part of the query definition. To specify the sort order, use the Sort row in the query grid. When you place the cursor in one of the cells in the Sort row, you see a drop-down arrow. You can choose Ascending, Descending or Not Sorted to specify the sort order.
When you specify a sort order for more than one field Access works from left to right: The field furthest to the left in the grid that has a sort order specified will be the primary sort key--any other sorted fields will be secondary. We’ll have a look at this in the following Simulation.
Specify Query Sort Order
Add a calculated field to the query in the next lesson.
Specifying Sort Order - Exercise
Practice refining your query by defining a sort order.
Specifying Sort Order - Exercise

Custom Sort Order for Displaying Records
I wrote an application one time where I tracked the work I did over the course of a week. This database also had a feature where I could send my manager an e-mail that displayed these items under category headings.
For example, customer-related activities such as responding to questions or attending user group meetings were included under my Customer heading, while coaching or mentoring were included under a heading called People Management. This database worked well for me, and for my headings, but I wanted to make it more generic. So, the database was also able to customize the category headings, as well as the order in which they appeared in the e-mail.
One person might choose to show the People Management category at the top of the e-mail, while another might choose to show Customer activity at the top.