G
Gibson
I am trying to create a new field in the backend .mdb via code. Being
unexperienced at this I have been using various portions of code I have
found in books and at web sites. The code below I understand creates a new
table and then puts the field NewField in that table. I tried OpenRecordset
with the name of the table I want to open instead of CreateTableDef thinking
that may open the table, no luck. How can I simply open an existing table
instead of creating a new one and how do I add properties like caption and
field size. Thanks so much for any suggestions.
Set dbsData = OpenDatabase("C:\Program Files\Directory\BackEnd.MDB")
Set tdfNew = dbsData.CreateTableDef("NewTable")
With tdfNew
.Fields.Append .CreateField("NewField", dbText)
dbsData.TableDefs.Append tdfNew
End With
unexperienced at this I have been using various portions of code I have
found in books and at web sites. The code below I understand creates a new
table and then puts the field NewField in that table. I tried OpenRecordset
with the name of the table I want to open instead of CreateTableDef thinking
that may open the table, no luck. How can I simply open an existing table
instead of creating a new one and how do I add properties like caption and
field size. Thanks so much for any suggestions.
Set dbsData = OpenDatabase("C:\Program Files\Directory\BackEnd.MDB")
Set tdfNew = dbsData.CreateTableDef("NewTable")
With tdfNew
.Fields.Append .CreateField("NewField", dbText)
dbsData.TableDefs.Append tdfNew
End With