Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Adding a Single-Field Index to an Existing Table with SQL command

Sub SingleField_Index2()      Dim conn As ADODB.Connection      Dim strTable As String      On Error GoTo ErrorHandler      Set conn = CurrentProject.Connection          strTable = "myTable"      conn.Execute "CREATE INDEX idxCity ON " & strTable & "(SCity) ;"  ExitHere:      conn.Close      Set conn = Nothing      Exit Sub  ErrorHandler:      MsgBox Err.Number & ":" & Err.Description      Resume ExitHere  End Sub