Sub CreateTable()
Dim db As DAO.Database
Dim tbl As DAO.TableDef
Set db = CurrentDb()
Set tbl = db.CreateTableDef("MyTable")
tbl.Fields.Append tbl.CreateField("ID", dbLong)
tbl.Fields.Append tbl.CreateField("Name", dbText, 255)
tbl.Fields.Append tbl.CreateField("Age", dbInteger)
db.TableDefs.Append tbl
End Sub
This code creates a new table called "MyTable" with three fields: "ID", "Name", and "Age". The "ID" field is of type "Long", while the "Name" field is of type "Text" with a maximum length of 255 characters, and the "Age" field is of type "Integer". The table is then appended to the database.
