Change Field Names In Table w/Macro

  • Thread starter Thread starter DBarker
  • Start date Start date
D

DBarker

Is there a way to take an existing table and run a macro
that will change the names of the fields? Or do I have to
do this by programming a module. The field names will be
consistent all the time. What I am doing is pulling data
from a live database and then manipulating it to show the
fields that I want and not the naming conventions of the
live database since they are not easily understood.

Thanks,
Debbie
 
Debbie,

No, sorry, this is not possible, either with a macro or with a VBA
procedure. The only way you can achieve this purpose is to add new
fields to the table, with the names you want, run an update query to set
the value of the new fields to the value of the existing fields, and
then delete the existing fields. To do these steps with a macro, you
would use RunSQL macro actions to run ALTER TABLE statements, and an
OpenQuery action to run the Update.

But to be honest, I am wondering what the problem is with the existing
fields. Since you are unlikely to see the tables in the course of
normal usage of the database, does it really matter what the field names
are?
 
Actually, that's not correct, Steve. You can change the name of a field
without any problems.
CurrentDb().TableDefs("MyTable").Fields("MyOldFieldName").Name =
"MyNewFieldName" will work.

You're probably thinking of trying to change the field type.
 
<blush> Thanks, Doug. Yes, I was getting confused with a field type change.

Sorry, Debbie, I gave you incorrect advice!
 
Back
Top