Adding column to exising dbf file
Posted on 2007-10-14
I have an existing dbf table, that I would like to add an additional column.
I have tried 2 different ways without any success.
1st way. (gDBDIr is the directory where the dbf files exist)
Set mydb = OpenDatabase(gDBDir, False, 0, "DBase 5.0;")
Set myTDef = mydb.TableDefs("SHDIV")
.Fields.Append .CreateField("NewField", dbText, 1)
On the CreateField line I get an error:
Run-time error '3282': Operation not supported on a table that contains data.
2nd way I tried. (MyConn is a connection that is setup and opened)
MyConn.Execute "ALTER TABLE SHDIV ADD COLUMN NewField CHAR(25) NULL;"
I get the following error
Run-time error '-2147467259 (80004005)': Operation not supported on a table that contains data.
Any help would be greatly appreciated.
Thanks in advance