"Dirk Goldgar" <(E-Mail Removed)> wrote in message
news:465E1B02-0DCF-42CB-83A6-(E-Mail Removed)...
> "Bob Howard" wrote in message
> news:%(E-Mail Removed)...
>> Can someone give me a snippet of code to modify the fieldsize property of
>> a text field (call it "FieldA") in a table (call it "TableA") in a
>> database (call it "DatabaseA").
>>
>> It was 10, and now needs to be 11.
>>
>> I don't know if this needs to be DAO or can be done in a simpler way. I
>> just know i need to do it from VBA code.
>
>
> Not DAO, but this ought to do it if run within DatabaseA:
>
> CurrentDb.Execute _
> "ALTER TABLE TableA ALTER COLUMN FieldA Text(11)", _
> dbFailOnError
Just to add onto Dirk's reply, it's not possible to change the size of a
field using DAO. Once the field has been added to the Fields collection of
the table, the Size property becomes read-only.
If there's a reason why you must use DAO (and to be honest I can't imagine
one), you'd have to add a new field of the correct size, run an update query
to populate the new field with the value of the old field, delete the old
field and rename the new field to the name of the old field (then, of
course, compact the database, although you should probably do that after
using DDL to make the change too)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)