Article ID: 112107
Article Last Modified on 11/6/2000
Table: Interviews
--------------------------
Field Name: CustomerID
Data Type: Number
Field Size: Long Integer
Field Name: InterviewerID
Data Type: Number
Field Size: Long Integer
Field Name: Appointment
Data Type: Date/Time
'---------------------------------------------------------------
'PURPOSE: Adds a multiple-field index to a table.
'ACCEPTS: Nothing.
'RETURNS: Nothing.
'---------------------------------------------------------------
Function AddMultiIndex ()
Dim DB As Database, TDef As TableDef
Dim Idx As Index, Fld As Field
Set DB = DBEngine.Workspaces(0).Databases(0)
' Open the table definition.
Set TDef = DB.TableDefs("Interviews")
' Create an index called PrimaryKey for this TableDef
' .. and turn on the Primary and Required properties.
Set Idx = TDef.CreateIndex("PrimaryKey")
Idx.Primary = True
Idx.Required = True
Idx.Ignorenulls = False
' Create an index field with the same name as a table field,
' .. then append it to the index.
Set Fld = Idx.CreateField("CustomerID")
Idx.fields.Append Fld
' Do the second field the same way.
Set Fld = Idx.CreateField("InterviewerID")
Fld.Attributes = DB_DESCENDING
Idx.fields.Append Fld
' Append the index to the TableDef.
TDef.indexes.Append Idx
End Function
Keywords: kbhowto kbprogramming KB112107