Create Index using SQL in Access 2000 Table 
Author Message
 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



Sun, 21 Sep 2003 16:56:54 GMT  
 Create Index using SQL in Access 2000 Table
Hello Andrew
I think CREATE INDEX only creates a temporary search index on  an existing
table. If you wish to add a column to an existing table, you have to use

ALTER TABLE TableName ADD COLUMN FieldName TEXT/INTEGER/DATE or whatever

Sukesh


Quote:
> 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



Mon, 22 Sep 2003 00:06:26 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Create Index using SQL in Access 2000 Table

2. Create Index using SQL in Access 2000 Table

3. Access 2000 VBA/SQL - cannot create pseudo-index on linked SQL Server table

4. Creating Tables in Access 2000 using SQL Text files

5. Transfer Record within Access 2000 Tables using VB6 Sql

6. Create Dynamic Table in Access 2000 using ADO

7. Transfer Record within Access 2000 Tables using VB6 Sql

8. Referencing an existing table index in VB with Access 2000

9. HELP!!..accessing access 2000 with linked SQL Server tables

10. VBA - Access 2000 Create a table and access the fields

11. need help opening a two field index with VB6 using access 2000

12. Sorting an Access table to improve access from SQL (despite the use of an index)

 

 
Powered by phpBB® Forum Software