Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Standardise Field Properties

Author  Topic 

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2005-08-12 : 03:17:45
I want to standardise field properties for all fields of the same type in an existing database (hundreds of them).

(eg all text fields to 255 chars, all text fields to allowzerolength etc)

The problem is that these properties are read-only for fields which are appended to a table. But for an extsing table, all fields are appended and so it looks as if these properties can't be changed.

Of course the UI allows you to change them, so there must be a way of doing it in VBA using the DAO object model.

Does anyone out there know a better way than the following: (if not, please don't post back)

My existing method:
* create a new field
* copy existing field properties to new field
* modify the particular property I want to standardise
* append the field to the table
* run a query to copy values from the old field to the new field
* delete the old field
* create a new field2
* copy properties from new field to new field2
* append the field2 to the table
* run a query to copy values from the new field to the new field2
* delete the new field

This feels cumbersome and dangerous to me.

What's even worse is that if the field is indexed or is part of a key, then this method won't work at all...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
   

- Advertisement -