Sorting in Access is the process of rearranging records in a specific order. Sorting data can create a significant impact on the usability of Access queries and reports. Sorting can occur before or after executing a query. In the datasheet view, a query can be sorted after running the query by using the Sort Ascending and Sort Descending buttons in the Sort & Filter group of the Home tab.
To create more complex sorting criteria, use the Query Design window to create multi-field sorts.
Multi-field sorting requires the use of primary, secondary and potentially, tertiary sorting fields. Using Access’ Query Design View, fields can be arranged in any order to accommodate the desired order. It is important to comply with the sorting rules inherent with the various data types of each field (see table to the left). Access will sort the fields in the Query Design from left to right. However, this can by manipulated by adding duplicate fields to the grid, specifically for sorting purposes. The key to this strategy is to utilize the Show checkbox for these sort-only fields. Clearing the Show checkbox will prevent these fields from displaying the Datasheet results, but their sorting mission will still be accomplished! Using Query Design also affords the ability to sort one field in Ascending order and another in Descending order in the same sort process.
In the example below, the goal is to sort the records primarily by Last Name. However, some records might share the same Last Name. Therefore, if there are duplicates, the First Name field will serve as the secondary sort criteria. Furthermore, it is desired that the results set display the records with the First Name field to the left of the Last Name field. This necessitates the use of a duplicate First Name field that will only be used for sorting purposes. Also notice that the Show checkbox is cleared for this duplicate field, so as not to confuse the layout of the results set. Hiding a field, by clearing the Show checkbox. can also be used for applying Criteria restrictions on a field that is not desired to be displayed in the results set, but is needed to narrow the results. This is popular with the sensitive data, like Salary or Credit Limits.