Completely Free .NET word API

Resources » Code Snippets » MS Access

MS Access : Remove Index From MDB programmatically

Updated: Category: MS Access
Author: Member Level: GoldPoints: 10

The following VBA code is used to remove the index from MS Access table programmatically.

We need to assign the database to Database type variable.

Then get the table value into tabledef collection. Then using delete command we can remove the indexes.

Sub RemoveIndexFromMSAccessDB()

'Declaration of Variables
Dim indexName As String
Dim AccessDb As Database
Dim Td As TableDef

'Error Handler
On Error Go to ErrHandler

'Assign the database
Set AccessDb = OpenDatabase("C:\Test.MDB")

If Err.Number <> 0 Then

'failed to open access database

MsgBox "Error " & Err.Description & "Err No " & Err

Exit Sub
End If

'Assign Index

indexName = "MyIndex"

'get table

Set Td = AccessDb.TableDefs("MyTable1")

If Err.Number <> 0 Then

'failed to get table
GoTo ErrHandler

End If

With Td

On Error Resume Next
.Indexes.Delete IndexName

End With


MsgBox "Error " & Err.Description & "Err No " & Err

End Sub

Did you like this resource? Share it with your friends and show your love!

Responses to "MS Access : Remove Index From MDB programmatically"

No responses found. Be the first to respond...


Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Phagu Mahato
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India