Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

ACC2000: How to Add an Index in an Access Database


View products that this article applies to.

Summary

An index helps Microsoft Access find and sort records faster. Access uses indexes in a table the same way that you would use an index in a book. To find data, Access looks up the location of the data in the index.

You can create indexes based on a single field or based on multiple fields. Multiple-field indexes enable you to distinguish between records that may have the same value in the first field.

↑ Back to the top


More information

Deciding Which Fields to Index

Fields that you should consider indexing are fields that you search frequently, fields that you sort, or fields that you join to fields in other tables.

The primary key of a table is automatically indexed, and you cannot index a field whose data type is OLE Object. For other fields, you should consider indexing a field if all the following apply:
  • The data type of the field is Text, Number, Currency, or Date/Time.
  • You anticipate searching for values stored in the field.
  • You anticipate sorting values in the field.
  • You anticipate storing many different values in the field. If many of the values in the field are the same, the index may not significantly speed up queries.

Creating a Single-Field Index

To create a single-field index, follow these steps:
  1. Start Microsoft Access, and then open the database that you are working with.
  2. Open a table in Design view.
  3. Click the field that you want to create an index for.
  4. Under Field Properties, click the General tab, click in the Indexed property box, click the arrow, and then click Yes (Duplicates OK) or Yes (No Duplicates).

Creating Multiple-Field Index

If you will often search or sort by two or more fields at a time, you can create an index for that combination of fields. For example, if you often set criteria for LastName and FirstName fields in the same query, you should create a multiple-field index on both fields.

When you sort a table by a multiple-field index, Microsoft Access sorts first by the first field that is defined for the index. If there are records with duplicate values in the first field, Microsoft Access sorts next by the second field defined for the index, and so on.

You can include up to 10 fields in a multiple-field index.

To create a multiple-field index, follow these steps:
  1. Open the table in Design view.
  2. On the View menu, click Indexes.
  3. In the Indexes dialog box, type a name for the index in the first blank row of the Index Name column. You can name the index after one of the index fields or use another name.
  4. Click in the Field Name column, click the arrow, and then select the first field for the index.
  5. Click in the next row in the Field Name column, click the arrow, and then select the second field for the index. (Leave the Index Name column blank in that row.) Repeat this step until you have selected all the fields that you want to include in this index.

↑ Back to the top


Keywords: KB304272, kbhowto

↑ Back to the top

Article Info
Article ID : 304272
Revision : 4
Created on : 9/19/2012
Published on : 9/19/2012
Exists online : False
Views : 244