Objective 5. Sort Data in a Query

You can sort the results of a query. Because the results of a query are formatted like a table in Datasheet view, the process for sorting is similar to sorting in a table. Records can be sorted in either ascending or descending order. Data in a query can be sorted either from the Datasheet view or from the Design view.

If you add a sort order to the design of a query, it remains as a permanent part of the query design. If you use the sort buttons in the Datasheet view, it will override the sort order of the query design, and can be saved as part of the query, but will not display in the query design grid.


[Page 986]

Activity 2.8. Sorting Data in a Query

1.

With your 2A Query1 displayed in Design view, under Club Affiliation, click in the Sort row to place the insertion point there and display an arrow. Click the Sort arrow, and then from the displayed list, click Ascending.

The results of the query will be sorted alphabetically by Club Affiliation.

2.

Under Pledge Amount, click to display the Sort arrow, and then click Descending. In the Query Design view, you can sort on two fields that are not adjacent to each other and you can sort in ascending order on one field and descending order on another field. Recall that you could not sort in this manner directly in a table, nor could you do so using a simple filter.

3.

On the Query Design toolbar, click the Run button , and then compare your screen with Figure 2.16.

Figure 2.16.

Access sorts fields left to right. The records are sorted first in alphabetical order by the Club Affiliation fieldthe leftmost fieldand then within each club, in descending orderfrom the highest to lowest amountby the Pledge Amount fieldthe rightmost field.

[Page 987]

Категории

© amp.flylib.com,