0

I have like 20 datasets, each with 28 fields without the first row having fieldnames. So MS Access assigned 'Field1', 'Field2'.... 'Field28' as fieldnames for each column. I'd like to know if it is possible to run a query to rename them? I couldn't find any information online and I tried manually entering the names but it is taking too long.

HansUp
  • 95,961
  • 11
  • 77
  • 135
dropkick
  • 1
  • 1
  • 4

1 Answers1

2

Access SQL does not support changing the name of an existing field.

You could create a SELECT query and alias the field name:

SELECT Field1 AS FieldA FROM YourTable;

Then you would use the query instead of the table whenever you want to display the aliased name.

Or you could use a "make table" query to create a new table with the new field name:

SELECT Field1 AS FieldA INTO NewTable FROM YourTable;

Or you could execute an ALTER TABLE statement to add the new field, then an UPDATE to populate the new field with the old field data, and finally DROP the old field. But that seems like too much work.

Instead of SQL, consider using VBA to rename the field:

CurrentDb.TableDefs("YourTable").Fields("Field1").Name = "FieldA"
HansUp
  • 95,961
  • 11
  • 77
  • 135