This article was previously published under Q199005
Advanced: Requires expert coding, interoperability, and multiuser skills.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
Sub CreateTables()
Dim ADOCon As New ADODB.Connection
Dim ADOCmd As New ADODB.Command
Dim MyStr As String
Dim i As Integer, j As Integer
' Use active Access connection.
Set ADOCon = CurrentProject.Connection
For i = 1 To 20
ADOCon.Execute "CREATE TABLE tblTest" & i
For j = 1 To 200
ADOCon.Execute "ALTER TABLE tblTest" _
& i & " ADD Field" & j & " Text"
Next
Next
Application.RefreshDatabaseWindow
End Sub
?FileLen(CurrentDb.Name)
Option Explicit
Sub ADOX_CreateTables()
Dim cat As New ADOX.Catalog
Dim conn As New ADODB.Connection
Dim tbl As New ADOX.Table
Dim i As Integer, j As Integer
Set conn = CurrentProject.Connection
Set cat.ActiveConnection = conn
For i = 1 To 20
With tbl
'Create a new table
.Name = "tblTest" & i
'Add 200 text fields
For j = 1 To 200
.Columns.Append "Field" & j, adVarWChar, 50
Next j
End With
'Append the table into the Catalog's tables collection
cat.Tables.Append tbl
Set tbl = Nothing
Next
Application.RefreshDatabaseWindow
End Sub
ADOX_CreateTables
?FileLen(CurrentDb.Name)
?FileLen(CurrentDb.Name)
Keywords: KB199005, kbusage, kbnofix, kbbug