Article ID: 197953
Article Last Modified on 6/23/2005
Sub CreateTables()
Dim db As Database
Dim sql As String
Dim i As Integer, j As Integer
Set db = CurrentDb()
For i = 1 To 20
sql = "CREATE TABLE Table" & i & " ("
For j = 1 To 200
sql = sql & "Field" & j & " TEXT,"
Next
sql = Left$(sql, Len(sql) - 1) & ");"
db.Execute sql
Next
Application.RefreshDatabaseWindow
End Sub
?FileLen(CurrentDb.Name)This function returns the file size in bytes of the currently opened database (Northwind.mdb). Note of the current size.
Option Explicit
Sub CreateTables()
Dim db As Database
Dim t As TableDef
Dim f As Field
Dim i As Integer, j As Integer
Set db = CurrentDb()
For i = 1 To 20
Set t = db.CreateTableDef("Table" & i)
For j = 1 To 200
Set f = t.CreateField("Field" & j)
f.Type = dbText
f.size = 50
t.Fields.Append f
Next
db.TableDefs.Append t
Next
Application.RefreshDatabaseWindow
End Sub
CreateTablesNote that twenty tables are added to the database, each with two hundred fields.
?FileLen(CurrentDb.Name)Note that the file size of Northwind.mdb is now reported to be more than 52 megabytes.
?FileLen(CurrentDb.Name)Note that the file size of Northwind.mdb after compacting is now back to the size you saw in step 4.
Additional query words: pra
Keywords: kbbug KB197953