Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create new field on linked table?

Status
Not open for further replies.

goldbird

Programmer
Jul 21, 2003
1
US
Can anyone teach me how to create new field on linked table? Thank You!
 
Hi

That is a Linked Access table?

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 - UK
 
Hi

That is a Linked Access table?

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 - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top