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:
- Start Microsoft Access, and then open the database that you are working with.
- Open a table in Design view.
- Click the field that you want to create an index for.
- 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:
- Open the table in Design view.
- On the View menu, click Indexes.
- 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.
- Click in the Field Name column, click the arrow, and then select the first field for the index.
- 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.