Considerations when sorting records in a table, query, form, or report
- Sort orders are saved with a table, query, or form. If you base a new form or report on a table or query that has a sort order saved with it, the new form or report inherits the sort order.
- Microsoft Access will sort on up to 255 characters, in one or more fields, in the results of a query or advanced filter.
- Sort order depends on the language setting you specify in the Options dialog box at the time you create your database. To check or change this setting, click Options on the Tools menu, and then click the General tab to see the setting under New Database Sort Order. If your database contains linked tables from a database that uses a different language sort order, Microsoft Access uses the sort order of the database that contains the link to the table, not the database where the table is stored.
- If the design grid for the query or filter contains the asterisk from the field list, you can't specify a sort order in the design grid unless you also add the fields you want to sort on to the design grid. For more information, click .
- To sort dates and times from earlier to later, use ascending order. Use descending order to sort from later to earlier.
- Numbers stored in Text fields are sorted as strings of characters, not numeric values. Therefore, to sort them in numeric order, all text strings must be the same length with shorter numbers padded with leading zeros. For example, the result of an ascending sort of the text strings "1", "2", "11", and "22" will be "1", "11", "2", "22". You must pad the single-digit numbers with a leading zero for the strings to be sorted properly: "01", "02", "11", "22". For fields that don't contain Null values, another solution would be to sort on the numeric values of the strings by using the Val function. For example, if the Age column is a Text field that contains numeric values, specifying Val([Age]) in a Field cell and specifying a sort order in its Sort cell will put the records in the correct order. If you are only storing numbers or dates in a Text field, consider changing the field's data type to Number, Currency, or Date/Time in the table where the field is stored. Then, when you sort on the field, the numbers or dates will sort in numeric or date order without requiring leading zeros.
- When you sort a field in ascending order, any records in which that field is blank (contains a Null value) are listed first. If a field contains records with both Null values and zero-length strings, the fields with null values appear first in the sort order, immediately followed by the zero-length strings.
- You can't sort a field whose data type is Memo, Hyperlink, or OLE Object.