Create in index in VB Code

  • Thread starter Thread starter Jonathan Mulder
  • Start date Start date
J

Jonathan Mulder

Can someone direct me to some sample code that:
1) Deletes an existing index,
2) Creates an index

The Northwind example doesn't help much.

Thanks,

Jonathan Mulder, California Dept. of Water Resources
 
To delete an index using DAO

CurrentDb.TableDefs("tableName").Indexes.Delete "indexName"

To create a new index in DAO

Set ndx = New DAO.Index
With ndx
.Name = "tableId"
.Fields.Append .CreateField("columnName")
End With
CurrentDb.TableDefs("tableName").Indexes.Append ndx

There are other properties about the index that can be set.
refer to the DAO Help topics.

Hope This Helps
Gerald Stanley MCSD
 
Back
Top