ACC1x: Record Sort Order Is Different Than ExpectedLast reviewed: May 28, 1997Article ID: Q105978 |
The information in this article applies to:
SYMPTOMSNovice: Requires knowledge of the user interface on single-user computers. When you view data in a datasheet, combo box, or list box, the record order is different than you expect. For example, text fields may appear out of alphabetical order or numeric fields may appear out of sequence.
CAUSEMicrosoft Access has two default sort orders, insertion order and primary key order. These sort orders are used at different times, causing records to appear to be sorted differently than you expect.
RESOLUTIONIf you want to see the insertion order for a table with a primary key field, remove the primary key from the table. For more information on removing a primary key, search for "primary key" then "Deleting the Primary Key" using the Microsoft Access Help menu. If you want to store records in a different order than insertion order, build a new table with a custom sort. To do this, use a make-table query with a specified sort order. For more information on make-table queries, see the Microsoft Access "User's Guide," Chapter 7.
STATUSThis behavior is by design.
MORE INFORMATIONInsertion order is the order in which records are entered and stored in a table. This order may not be in alphabetical or numeric sequence, since records are often entered in a random order. Primary key order is based on the field or fields in a primary key. This order has no effect on the way records are stored in a table; the records are still stored in insertion order. Primary key order changes only the way the records are displayed. If the underlying table for a table, form, subform, or query datasheet has no primary key, the data will be displayed in insertion order. If the table has a primary key, the data will be displayed in primary key order. There are two exceptions to this rule. For query datasheets, insertion order will be used for a query that has specific criteria but no specific sort order, even if the underlying table has a primary key. For combo boxes and list boxes, insertion order is used even if the underlying table has a primary key.
Steps to Reproduce BehaviorThe following four examples demonstrate the two default record orders and the two exceptions described above. Note that all the examples use the sample database NWIND.MDB. Viewing Records in Insertion Order:
Viewing Records in Primary Key Order:
Viewing Records in Insertion Order Despite a Primary Key:
Category ID ----------- SEAF APPZNote that SEAF appears before APPZ even though Category ID is a primary key field. Microsoft Access is using insertion order because the query includes specific criteria but no specific sort order. Viewing Combo Box Items in Insertion Order:
|
Keywords : kbusage TblPriky
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |