Set Field size in VBA

  • Thread starter Thread starter Vincent
  • Start date Start date
V

Vincent

I'm want to set the fieldsize of some fields in some
table...
I use a For loop to run through all fields but when a want
to set the size property
(like this: rst.Fields(i).size = 12) I get a runtime error
3219 "Invalid operation"
How comes... apparently in the help it's not said that the
property is Read-only.
Thanks for your help.
 
I don't believe you can resize a field like that.

If you are using Access 2000 or later, with a reference to the ADO library,
you can change the field size like this:
strSQL = "ALTER TABLE MyTable ALTER COLUMN MyField TEXT(12);"
CurrentProject.Connection.Execute strSQL

If you must work with DAO, the typical workaround is to create another field
of the desired size, exeucte an Update query to copy the data from the old
field, and then delete the old field.
 
Thank you very much Allen!!! Your first solution seems to
me the most elegant... Thanks again... dum from me that I
didn't think about it before... but that why newsgroup
exist...
Vincent
 
Back
Top