Sorting the records in your report
You can sort a report by sorting the record source - the table or query that provides the records for the report - before you print. But a more foolproof method is to use the Group, Sort, and Total pane to make a group for the field(s) by which you want to sort, even if you don't want to print anything extra when the field value changes. When you tell Access to group by a field, you get sorting thrown in for free. Selecting without a header section and without a footer section in the Group, Sort, and Total pane tells Access to sort by the field - but not to print any grouping sections.
To sort the records in a report by two fields, decide which field is the primary sort field and which is the secondary one. The secondary sort field works like a tiebreaker, used only when two or more records have the same value for the primary sort field. For example, to sort order records by customer name, you usually sort by last name (primary sort field) and first name (secondary sort field).
When you add a group to your report, Access automatically sorts the group in ascending order (you can change this to descending order) based on the field on which you grouped the report. If you have a large number of records, you may want additional sort fields (for example, you could sort a mailing list by ZIP code, then last name, and then first name).
You can sort by a calculated value that is not one of the fields in the record source of the report. Just enter an expression in the Field/Expression column of the Sorting and Grouping dialog box. For example, if you print a listing of products, you may want to sort them by profit margin - by [Selling Price] -[Purchase Price]. You can type that expression into the Field/Expression column (hence the name of the column!).
In this tutorial:
- Creating and Editing Reports
- What are Forms and Reports
- Creating Reports Automatically
- Running the Report Wizard
- Creating Simple Reports
- Editing Reports in Design View
- Adding page headers, footers, and numbers
- Adding sections that group your records
- Sorting the records in your report
- Calculating group subtotals and report totals
- Formatting Tips and Tricks
- Copying Forms to Reports
- Adding and Formatting Subreports
- Displaying Empty or Long Fields
- Creating Mailing Labels