Specify Access Sort order
Specify Query Sort Order
- This datasheet is the result of a query. It seems to be sorted by date. However, you'd like to sort it by Company.
Click the View button to see the query in Design view.
- To sort by Company you need to set a sort order in the Sort row for the Company field. Click the Sort row in the Company column to see the arrow for the drop-down list.
- Display the drop-down list by clicking the arrow and choose Ascending. Ascending sorts text data from the beginning of the alphabet to the end, date data from the earliest date to the latest, and number data from the smallest to the largest.
- Now that you have defined the sort order, have another look at the datasheet by clicking the View button on the toolbar.
- Although you can only see one company listed (except for the last record on the screen) the records do appear (and, in fact, are) to be sorted by company. However, the records for ABC Webworks, although they all appear at the top of the datasheet, seem to be in no particular order. You can specify a secondary sort field to put records with the same value in the primary sort field (in this case, all the records for ABC Webworks) in a particular order. Click the View button to return to Design view to further define the sort order for the query.
- Set Project ID as the secondary sort field. That way all the work for one project will appear together. Click the Sort row in the Project ID column to see the arrow for the drop-down list.
- Display the drop-down list and choose Ascending.
- Now view the datasheet again by clicking the View button.
- Here you see that now in addition to sorting by company the datasheet is also sorted by project ID. If you want, you can also sort by date--but remember that Access works from left to right when sorting, so it would sort first by Company, then by Project ID, then by Date because that is the order the fields appear in the query design.