Link to home
Start Free TrialLog in
Avatar of SpaceCoastLife
SpaceCoastLife

asked on

Renaming field in code in an Access table

This should be a piece of cake for you experts!

In code, what's the syntax for renaming the field in a existing table? I'm thinking probably only one line but haven't figured it out. I'm using Access 2002
Avatar of PatHartman
PatHartman
Flag of United States of America image

I hope this is for some utility you are building for yourself because it is not something that would ever be used in a normal application.

Use the fields collection of the table.  I have no idea if this would work since this is not something I would ever do.
Actually, I don't think you can change the name of the field in code.

I think you have to do it manually, or create a new column with the new (which you can do in code), then copy the values from the old field (also can do in code), and then delete the old column (also can be done in code).

Not sure why you would want to do this via code.  This is a database maintenance thing and would involve changing that name in all references to that field (queries, code, control references).

Dale
ASKER CERTIFIED SOLUTION
Avatar of Paul Cook-Giles
Paul Cook-Giles
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SpaceCoastLife
SpaceCoastLife

ASKER

Not to worry. It's a tool. Never in production. Code works great. Thanks!