Fields Property

See Also374TWGI              Example2JGTOVE>Low (Professional Edition Only)

Applies To

Index object1WDWMJT.


Determines which TableDef fields are key fields in an index6SGX4U.  Read-only when the Index is a member of a collection.  Read/write only in the Professional Edition with a new object not yet appended to an Indexes collection.


index.Fields [ = fieldlist ]


An Index object can have one or more fields representing key values for each record.  Field names are separated by semicolons.

To get the fieldlist for an index, specify both the index and the recordset:

Key = Data1.Recordset.Indexes("PrimaryKey").Fields


With a data control, the Index must be a member of an Indexes collection.  To get the value of this property, you can use the control's Recordset property, or you can use the TableDefs collection of the Database property of the data control.  For example:

Key = Data1.Database.TableDefs("Areas").Indexes("PrimaryKey").Fields


In the Professional Edition, you can use an object variableZ3R9Q5 of type Index.  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 object.

Data Type


See Also


Append Method555NLF (Professional Edition Only)

Fields CollectionQ15ZEN

Indexes Collection1WAT5K

Name Property2016V9P


Unique Property2BEHFBA


Data Access Guide:

Chapter 2, "Database Management Using Visual Basic"

Fields Property Example (Professional Edition Only)

This example adds a new index to the Authors table.

Dim TempIndex As New Index               ' Create new Index object.
TempIndex.Name = "Full Name"             ' Set Index properties.
TempIndex.Fields = "LName; FName"
TempIndex.Unique = True
' Append the new Index to the Indexes collection.
MyDB.TableDefs("Authors").Indexes.Append TempIndex