CreateField

  • Thread starter Thread starter Lasse T
  • Start date Start date
L

Lasse T

Hello !!

This is probably a wery simple task but I cannot find the answer in help or
in the Usenet.

I´m workin on a project that is aready in use by some users. From time to
time i have been in need to update some of the tables with more fields. I
made a simple "updater" for my users, a small MDB with following code.

Set dbsnew = OpenDatabase("p:\mydatabase.mdb")
Set tdfNew = dbsnew.TableDefs("mytable")
With tdfNew
.Fields.Append .CreateField("mynewfield", dbText, 6)
.Fields.Append .CreateField("mycheckbox", dbBoolean)
End With

Now I have learned that not all of the users has done the updates and it has
been 3 och 4 of them so I was thinking of making a new "update.mdb" with all
of the updates. The problem is that i then need this code to check if the
field already exist and if it does, go on to creating the next field. So
that all the users can run the update, just in case. If I try to run the
above code on a db where the fields exists I get error.

Thanks in advance.

Lasse T
--------------
 
You can start your application with code that opens a recordset that
contains the new field. Then, when you try reference the field, trap the
potential error and add the field.
 
Back
Top