Index Object

See AlsovbobjIndexObjectSee              PropertiesvbobjIndexObjectProp

Description

An object contained in the Indexes collections of Table and TableDef objects.  Indexes are used to order records by one or more key fields within a table.  They speed up the process of finding records, and can enforce unique values in each field named in the Index.  An Index is stored in the database as a retrievable object.  A table can have none, one, or more indexes.

Remarks

The Name property of an Index object is not the same as the name of an object variableZ3R9Q5 to which it is assigned.  Unlike forms and controls, the Name property of an Index object is available at run time.

Professional Edition

In the Professional Edition, you can declare an object variable as an Index type.

A Table usually should have an index uniquely identifying each record, called a "primary key" index.  A primary key index is indicated with the Primary property of an Index object.

Although an Index can help find records quickly, if you are frequently updating a table with several indexes, it can actually slow down the updating process.  Creating a new Index on a table with many existing records can be a very lengthy process.  If there is no Index on a Table, finding records can be a lengthy process also.

To create an index for a Table

  1. Create a New Index object.

  2. Set its properties.

  3. Add it to the Indexes collection of a TableDef with the Append method.

 

An index can include one or more key fields.  The key fields of an index are defined in the Fields property of an Index object.  The Fields collection of a TableDef or recordset is not the same as the Fields property of an Index object.

The Seek method of a Table uses an index of the Table to find specific records.