Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/108235

From BetaArchive Wiki
Knowledge Base

DOCERR: Revised Index Property (Data Access)

Article ID: 108235

Article Last Modified on 1/8/2003


  • Microsoft Visual Basic 3.0 Professional Edition

This article was previously published under Q108235


Page 279 of the "Language Reference" discusses the Index Property (Data Access). It has some incorrect and misleading information. This article is a revised and corrected version of the entire Index Property (Data Access) section. Please replace page 279 with this article.


Index Property (Data Access)

Applies To

Table object


With data access, the Index property 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. The Index property is not available at design time and is available read/write at run time.


table.Index [ = indexname ]


The order of the data in a table is determined by the order in which the data is added to the table. To alter the order of records fetched from the table when using a Table object, set the Index property to the name of an index in the Indexes collection of the Table's TableDef object. For example, to set the index to be used on a Seek against the Titles table:

   Dim Tb as Table, Db as Database
   Set Db = OpenDatabase("Biblio.MDB")
   Set Tb = Db.OpenTable("Titles")
   Tb.Index = "PubID"
   Tb.Seek "=", 3

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.

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

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 new Index for the table and append it to the Table's Index Collection, or create a Dynaset or Snapshot that has a different sort order. To specify the sort order for Dynasets and Snapshots, use the Sort property after the Dynaset or Snapshot has been created. You can also set the order of a Dynaset or Snapshot by including an Order By clause in a SQL statement used to define the Dynaset or Snapshot.

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

Data Type


Additional query words: 3.00 docerr

Keywords: KB108235