Sort records (MDB)

Microsoft Office Access 2003

  1. Click the field you want to use for sorting records. To sort records in a subform, click the field you want to sort. To sort records in a subdatasheet, display the subdatasheet by clicking its expand indicator, and then click the field you want to sort.
  2. Click Sort Ascending Button image or Sort Descending Button image.

Note  In a form, you can sort on only one field at a time. In Datasheet view, when you sort the subdatasheet for one record, Microsoft Access sorts all the subdatasheets at that level. In a datasheet or subdatasheet, you can select two or more adjacent columns at the same time, and then sort them. Access sorts records starting with the leftmost selected column. When you save the form or datasheet, Access saves thesort order.

ShowSort records by using the design grid

  1. Open a query in Design view or display the Advanced Filter/Sort window for a table, query, or form.
  2. To sort on more than one field, first arrange the fields in the design grid in the order you want the sorts performed. Access sorts on the leftmost field first, then on the next field to the right, and so on. For example, to sort on the LastName field first and then on the FirstName field, the LastName field must be to the left of the FirstName field in the grid.
  3. In the Sort cell for each of the fields you want to sort on, click an option.
  4. To see the results of the query, click View Button image on the toolbar.

ShowSort records in a report

ShowSpecify a sort order

  1. Open the report in Design view.
  2. Click Sorting And Grouping Button image on the toolbar to display the Sorting And Grouping box.
  3. In the first row of the Field/Expression column, select a field name, or type an expression.

    The field or expression in the first row is the first sorting level (the largest set). The second row is the second sorting level, and so on.

    Note  When you fill in the Field/Expression column, Microsoft Access sets the Sort Order to Ascending.

Notes

  • You can sort on up to 10 fields or expressions in a report.

  • The Customer Labels report in the Northwind sample database sorts records by the values in three fields. To view this report, point to Sample Databases on the Help menu, click either Northwind Sample Database or Northwind Sample Access Project, and then open the Customer Labels report in Design view.

ShowReapply an inherited sort order

  1. Open the report in Design view, or if the report is already open, make sure it is selected.
  2. Click Properties Button image on the toolbar to display the report's property sheet.
  3. In the OrderByOn property box, click Yes to reapply it.

Note  If you specify a sort order in a report wizard or in the Sorting And Grouping dialog box in report Design view, it overrides the inherited sort order.

ShowSort records on a data access page

ShowSort records on a page

You can sort data on a data access page, including data that's grouped. For grouped data access pages, you can sort the list of groups or the records within a group.

  1. Open a data access page in Page view.
  2. Do one of the following:
    • In an ungrouped page, click the field you want to use for sorting records.
    • In a grouped page, expand the group that you want to sort, and then click the field you want to sort records on.

      Note  When you sort records within a group, the sort order applies only to that group. It does not affect the order of records in other groups.

  3. Do one of the following:
    • To sort in ascending order, click Sort Ascending Button image.
    • To sort in descending order, click Sort Descending Button image.

ShowTip

If the records are displayed in tabular format, simply click the label of the field you want to sort records on. The records will display in ascending order. To sort records in descending order, click the label again.

Notes

  • When you close the data access page, you'll lose the sort order. You can sort the records again when you open the page.
  • The order in which numbers, text, and special characters are sorted depends on the database and your regional settings in Microsoft Windows Control Panel.
  • This procedure doesn't apply to a Microsoft Office PivotTable Component, Spreadsheet Component, or Chart Component. These features can be sorted independently from the rest of the data on the data access page, and may also support additional sorting capabilities. For more information, click Help Button image on the toolbar for the PivotTable list, spreadsheet, or chart, and then search for "sorting."

ShowChange the default sort order on a page

  1. Open the data access page in Design view.
  2. Scroll to a section that belongs to the group for which you want to specify the sort order.
  3. Right-click the section bar, and then click Group Level Properties.
  4. In the DefaultSort property box, type the name of the field you want to sort on. If you want to sort on multiple names, separate each field name with a comma. If you want to sort in ascending or descending order, follow each name with a space and the keyword ASC or DESC, respectively. For example, type OrderDate DESC, OrderID ASC. If you don't specify the order, Microsoft Access sorts in ascending order.

Note  If the control you want to sort on is bound to an expression, you must type the alias of the control as displayed in its ControlSource property. For example, if the ControlSource property of the control you want to sort on is set to GroupOfExtendedPrice: ExtendedPrice, type GroupOfExtendedPrice in the DefaultSort property box.

ShowSort data in PivotTable or PivotChart view

ShowSort data in ascending or descending order

You can sort data that is displayed in natural or custom order in ascending or descending order.

  1. Open a datasheet or form in PivotTable view or PivotChart view.
  2. Do one of the following:

    ShowIn PivotTable view

    • To sort the data in a field based on the item labels, click the label of the field that contains the data you want to sort.

    • To sort the data in a field based on the summary values in a column, click a cell in the column that contains the values that you want to sort on.

    • To sort the data in a field based on subtotal or grand total values, click a subtotal or grand total value for the field that contains the data you want to sort.

    ShowIn PivotChart view

    • To sort numeric data in a series, click the series or a series point within the series you want to sort.
    • To sort items in a field alphabetically, click the category field or series field, or click a category axis label.
  3. On the PivotTable or PivotChart toolbar, click Sort Ascending Button image or Sort Descending Button image.

Notes

  • To sort on multiple fields, start by sorting the innermost field first and work backward, sorting the outermost field last.

ShowSpecify a custom sort order in PivotTable view

  1. Open a datasheet or form in PivotTable view.
  2. Select the item you want to move.
  3. Drag the selected item and drop it over the item above which you want to place it.
  4. Repeat steps 2 and 3 until you have the items in the order you want.

Notes

  • To switch from ascending or descending sort to custom sort, click Sort Ascending Button image or Sort Descending Button image on the PivotTable toolbar so that the button is not selected.
  • If a field with custom sorting has a parent field, each parent member will display the lower-level members in custom order.

Note  The order in which numbers, text, and special characters are sorted depends on the source data and your regional settings in Microsoft Windows Control Panel.