R
Rob Wills
This one line of untidy code works....
CurrentDb.TableDefs("TableName").Fields.Append
CurrentDb.TableDefs("TableName").CreateField("New_Field", dbDouble)
=======================
However this doesn't....
With CurrentDb.TableDefs("TableName")
.Fields.Append .CreateField("New_Field", dbDouble)
End With
I have now found another way to get the code to work which I'll show below,
but I want to understand why the with statement is giving me an error saying
that the object is invalid or no longer set...
=======================
Dim DB as database
Dim tbldef as tabledef
dim fld as Field
set db = currentdb
set tblDef as db.tabledef("TableName")
set fld = tblDef.CreateField("New_Field",dbDouble)
tblDef.fields.append fld
================
Thanks in Advance
Rob
CurrentDb.TableDefs("TableName").Fields.Append
CurrentDb.TableDefs("TableName").CreateField("New_Field", dbDouble)
=======================
However this doesn't....
With CurrentDb.TableDefs("TableName")
.Fields.Append .CreateField("New_Field", dbDouble)
End With
I have now found another way to get the code to work which I'll show below,
but I want to understand why the with statement is giving me an error saying
that the object is invalid or no longer set...
=======================
Dim DB as database
Dim tbldef as tabledef
dim fld as Field
set db = currentdb
set tblDef as db.tabledef("TableName")
set fld = tblDef.CreateField("New_Field",dbDouble)
tblDef.fields.append fld
================
Thanks in Advance
Rob