Mega Code Archive

 
Categories / VisualBasic Script / Access
 

Creating an Index Based on Two Fields with SQL command

Sub MultiField_Index()      Dim conn As ADODB.Connection      Dim strTable As String      On Error GoTo ErrorHandler      Set conn = CurrentProject.Connection      strTable = "myTable"      conn.Execute "CREATE TABLE " & strTable _          & "(SId INTEGER, " _          & "SName CHAR (30), " _          & "SCity CHAR (19), " _          & "CONSTRAINT idxSupplierNameCity UNIQUE " _          & "(SName, SCity));"      Application.RefreshDatabaseWindow  ExitHere:          conn.Close          Set conn = Nothing          Exit Sub  ErrorHandler:          Debug.Print Err.Number & ":" & Err.Description          Resume ExitHere  End Sub