1 1 1 1 1 1 1 1 1 1 Rating 0.00 (0 Votes)

Für 32Bit und 64Bit Office Versionen

Problemstellung:

Wie kann ich ein Feld mittels ADO(X) löschen?


Verweis auf die Microsoft ActiveX Data Objects 2.X Library erforderlich
Verweis auf die Microsoft ADO Ext. 2.X for DDL and Security Library erforderlich

Public Sub DeleteIndexADOX(strTableName As String, strIndexName As String)
'*******************************************
'Name:      DeleteIndex   (Sub)
'Purpose:   löscht den angegebenen Index aus der gewählten Tabelle mittels ADOX
'Author:    Tommyk
'Date:      Februar 29, 2004, 04:38:28
'Inputs:    strTabName = Name der Tabelle, strIndexName = Name des Indexes
'Output:
'*******************************************
On Error GoTo ErrHandler
Dim cn As New ADODB.Connection
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
Dim idx As ADOX.Index
Set cn = CurrentProject.Connection
Set cat.ActiveConnection = cn
Set tbl = cat.Tables(strTableName)
Set idx = tbl.Indexes(strIndexName)
    tbl.Indexes.Delete idx.Name
    tbl.Indexes.Refresh
Set cat = Nothing
cn.Close
ExitHere:
    Exit Sub
ErrHandler:
    Dim strErrString As String
    strErrString = "Error Information..." & vbCrLf
    strErrString = strErrString & "Error#: " & Err.Number & vbCrLf
    strErrString = strErrString & "Description: " & Err.Description
    MsgBox strErrString, vbCritical + vbOKOnly, "Error in Sub: DeleteIndexADOX"
    Resume ExitHere
End Sub

Aufruf:

Call DeleteIndexADOX("tblNeu", "Test_I")


würde aus der Tabelle "tblNeu" den Index "Test_I" löschen

 

Ähnliche Artikel