Fred Hooper
fahooper at trapo.com
Sun Dec 4 12:09:21 CST 2005
The only way I've seen that works is that shown by Allen Beechick at http://aislebyaisle.com/access/vba_backend_code.htm. His code: (1) Gets and removes any indexes involving the field. (2) Renames the field (3) Creates a new field in the same place with the old name and new width (or, perhaps a new field type, etc.) (4) Copies the contents of the old field to the new field (5) Drops the old field (6) Re-applies the indexes Hope this helps, Fred Hooper -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin - Beach Access Software Sent: Sunday, December 04, 2005 12:45 PM To: AccessD at databaseadvisors.com Subject: [AccessD] Change Field Size Dear List: Close, but no cigar. I need to change the length of a field through code. I've got: Set wrk = DBEngine.Workspaces(0) Set db = wrk.OpenDatabase(gstrDatabaseName) Set tdf = db.TableDefs("tblPODetail") Set fld = tdf.Fields("fldPODPartDescription") fld.Properties("AllowZeroLength") = True fld.Properties("FieldSize") = 255 tdf.Fields.Append fld Set fld = Nothing Set tdf = Nothing Set db = Nothing Set wrk = Nothing but fld.Properties("FieldSize") = 255 errors with "property can only be set when the Field is part of a Recordset object's field collection. What am I doing wrong? MTIA, Rocky Smolin Beach Access Software http://www.e-z-mrp.com 858-259-4334 -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com