Create in index in VB Code

  • Thread starter Jonathan Mulder
  • 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
 
G

Gerald Stanley

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top