Microsoft Office 2000/Visual Basic Programmer's Guide |
The key to sorting data in an Access database is to define a query that specifies the sort order. You can do this by setting the Sort field in the query design grid to Ascending or Descending, or by including an ORDER BY clause in the SQL statement. You can ensure that you always display sorted data in a form, report, or data access page by specifying a sorted query as the record source.
You can speed up sort and find operations by defining indexes on Access tables. An index can be based on a single field or on multiple fields. The index can enforce certain rules for a field or set of fields, such as whether the indexed field contains unique values, whether to ignore Null values, and whether the index includes the primary key for the table. The primary key is a special type of index that uniquely identifies each record in the table.
You can add an index to a table by using the table design view in Access, or create it programmatically, through ADO or DAO. For more information about indexes, see Chapter 14, "Working with the Data Access Components of an Office Solution," or search the Microsoft Access Help index for "indexes."