Field properties

J

JT

Is it possible to change the properties of a field in a table
programmatically? For instance, I want to update the "Instruction" field in
the "Data" table by changing the size from 50 to 250.

I have a macro that will cycle through a number of folders and I want to add
some code to change the field size for a database in each folder.

Any help getting started would be appreciated. Thanks for the help.
 
A

Alex Dybenko

Hi,
most of the field properties you can change, but not size. For size you have
to create a new field with required size (there is a sample in online help),
copy data from old field to new using update query, delete old field and
then rename new to old name

--
Best regards,
___________
Alex Dybenko (MVP)
http://accessblog.net
http://www.PointLtd.com
 
J

John Spencer

You can use DDL (SQL) to change field size.

-- Code snippet --
Dim dbAny as DAO.Database
Dim strSQL as String
strSQL = "ALTER TABLE Data ALTER COLUMN Instruction TEXT(250) "
Set Dbany = CurrentDb()
DbAny.Execute strSQL, dbFailonError


--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 

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