Creating a Table in the Current Database with SQL statement
Sub CreateTable()
Dim conn As ADODB.Connection
Dim strTable As String
On Error GoTo ErrorHandler
Set conn = CurrentProject.Connection
strTable = "Employees"
conn.Execute "CREATE TABLE " & strTable & _
"(Id AUTOINCREMENT(100, 5)," & _
"lName CHAR," & _
"City Char (25), District Char (35)," & _
"YearEstablished Date);"
Application.RefreshDatabaseWindow
ExitHere:
conn.Close
Set conn = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Number & ":" & Err.Description
Resume ExitHere
End Sub
Related examples in the same category