HandsOn Adding a Single Field Index to an Existing Table

1. Switch to the Visual Basic Editor window and insert a new module.

2. In the module's Code window, enter the SingleField_Index2 procedure as shown below.

Sub SingleField_Index2()

Dim conn As ADODB.Connection Dim strTable As String

On Error GoTo ErrorHandler

Set conn = CurrentProject.Connection strTable = "Supplier!"

Part III

conn.Execute "CREATE INDEX idxCity ON " & strTable & _ "(SupplierCity) ;"


conn.Close Set conn = Nothing Exit Sub ErrorHandler:

MsgBox Err.Number & ":" & Err.Description Resume ExitHere End Sub

The procedure in Hands-On 21-3 adds a multiple-field index named idxSupplierNameCity to the Supplier2 table.

0 0

Post a comment