Index Property (Data Access}

See Also6FQU22              Example15OTIKL>Low (Professional Edition Only)

Applies To

Table objectv

Description

With data access, determines which existing index is the current index used to sort records in a Table and in recordsets created from that Table.  The default is blank.  Not available at design time; read/write at run time.

Syntax

table.Index [ = indexname ]

Remarks

The data in a table exists in the order it was entered.  Set the Index property to the name of an index to set the order to a named index in the Indexes collection of a TableDef object.

The specified index must already be defined.  If you set the Index property to an index that doesn't exist, or if the index isn't set when you use the Seek method, an error occurs.

To set this property with a data control, specify the TableDef, set the index, then Refresh the control:

Data1.RecordSource = "Publishers"
Data1.Database.TableDefs("Publishers").Index = "PrimaryKey"
Data1.Refresh

 

In the Professional Edition, you can create a new Index in a Table by creating a new Index object, setting its properties, then appending it to the Indexes collection of the Table's TableDef.

You can use the Indexes collection of a TableDef to determine what indexes are available in a Table.

The records in a Table can be ordered only according to the indexes defined for it.  To sort the Table records in some other order, create a Dynaset or Snapshot that has a different sort order.  To specify the sort order for Dynasets and Snapshots, use the Sort property.

The Index property of a control is not the same as the Index property of a data access object.

Data Type

String7WSH0XQ


See Also

Help:

Append Method555NLF

Index Property3MKW18P (Control Arrays)

Indexes Collection1WAT5K

NewLANNEW

Seek MethodZPTLKG (Professional Edition Only)

Sort Property2W0H8VD (Professional Edition Only)

TableDef ObjectK497U

 

Data Access Guide:

Chapter 2, "Database Management Using Visual Basic"

Chapter 3, "Creating Programs to Manipulate Data"

 

Programmer's Guide

Chapter 20, "Accessing Databases with the Data Control"


Index Property Example

See the example for the Unique property.