
Adding a new field to a table
I am trying to write a routine that adds a yes/no boolean field to an
already built table.
At the moment the code comes close, and will add a boolean field, but seems
to be in a differnent format to what I would expect.
This is the code
Public Sub AddNewMailList()
On Error Resume Next
Dim dbs As Database
Dim tbl As TableDef
Dim fld As New Field
Set dbs = DBEngine.Workspaces(0).OpenDatabase(GetPathToMainData)
Set tbl = dbs.TableDefs("wk-MailingLists")
Set fld = tbl.CreateField("NewBoolean", dbBoolean)
tbl.Fields.Append fld
dbs.TableDefs.Refresh
Set dbs = Nothing
End Sub
I am not sure if this is the best way of doing it or if I need to set other
properties after the field has been created. (Nor am I sure how to change
the properties of the field after it is created, but I will worry about
that when I have to....)
Any help or comments would be great.
Thanks,
Mike