Sub exaCreateTable()
Dim db As Database
Dim tblNew As TableDef
Dim fld As Field
Set db = CurrentDb
Set tblNew = db.CreateTableDef("MyTable")
Set fld = tblNew.CreateField("MyField", dbText, 100)
fld.AllowZeroLength = True
fld.DefaultValue = "Unknown"
fld.Required = True
fld.ValidationRule = "Like 'A*' or Like 'Unknown'"
fld.ValidationText = "Known value must begin with A"
tblNew.Fields.Append fld
db.TableDefs.Append tblNew
End Sub
|