modify field type of existing field in table

K

Kou Vang

Is it possible to modify the existing field type while in the tabledef
collection?

Set tdeF = db.TableDefs("CLMPMedians")
tdeF.Fields.Append tdeF.CreateField("StationNum", dbInteger)
tdeF.Fields("Median").Type = dbDouble

I don't see a reason to through in an ALTER TABLE SQL command if I'm already
doing indexing and field work in the TableDef. I have seen code to create a
new field with new type and new size, adding it to the table, then deleting
the old field and renaming the new field, is that really necessary? Is there
no "short cut" for modifying field type? I also tried:

fld.Type = dbDouble

Any suggestions?

Kou
 
A

Allen Browne

No. I don't believe DAO provides a way to modify the type of an existing
field.

Before the DDL approach was introduced, the only solution was to create a
new field of the desired type, copy the data over, and then delete the old
one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top