
Create Index using SQL in Access 2000 Table
Could someone please help me. I am getting a run-time error -2147467259
Table 'OrderItems' already has an index named 'Rack' when I try and create a
composite index consisting of the values in two existing columns. No column
named 'Rack' is created in the table and no values are written to the table.
I am using Microsoft Access 2000 and
Visual Basic 6 with Service Pack 4
applied. My code written in ADO is as follows:
Private Sub mnuAllocate_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim cmd As New ADODB.Command
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Data\highway.mdb;"
With cmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "CREATE INDEX Rack ON OrderItems
(OrderNumber,ItemNumber)"
.Execute
End With
With rs
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd
End With
End Sub