The simplest way is to open the mdb in which the table physically resides and use the table design view to add the column
If for any reason you cannot do that, or do not want to do that, you have two possibilities I can think of using DAO (note you need a reference to the DAO library to use DAO)
You could use the Tabledefs and Fields Collections something like (I suggest you visit help)
Dim ws as DAO.Workspace
Dim Db as DAO.Database
Dim tdf as DAO.tableDef
Dim fld as DAO.Field
Set ws = dbEngine.Workspaces(0)
SEt Db = ws.OpenDatabase("The path of your db")
Set tdf = db.Tabledefs("YourTable"
Set fld = NEW DAO.Field
' in here set type etc
tdf.fields.append fld
...etc etc
Alternatively this could be done with an SQl command
"ALTER TABLE ", again see help for syntax etc
Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
The simplest way is to open the mdb in which the table physically resides and use the table design view to add the column
If for any reason you cannot do that, or do not want to do that, you have two possibilities I can think of using DAO (note you need a reference to the DAO library to use DAO)
You could use the Tabledefs and Fields Collections something like (I suggest you visit help)
Dim ws as DAO.Workspace
Dim Db as DAO.Database
Dim tdf as DAO.tableDef
Dim fld as DAO.Field
Set ws = dbEngine.Workspaces(0)
SEt Db = ws.OpenDatabase("The path of your db")
Set tdf = db.Tabledefs("YourTable")
Set fld = NEW DAO.Field
' in here set type etc
tdf.fields.append fld
...etc etc
Alternatively this could be done with an SQl command
"ALTER TABLE ", again see help for syntax etc
Regards
Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now -
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.