I’ve just been importing some records from Excel to Access using VBA.
By default the names of the fields of the imported records are “F1″, “F2″, “F3″ etc.
To make things a little clearer I wanted to rename these imported fields to more meaningful names.
Here’s how to do it:
CurrentDb().TableDefs(TableName).Fields("OldName").Name = "NewName"
where:
TableName is the name of the table in which we want to change the names
“OldName” is the old name of the field
“NewName” is the new name we want to use for this field
When importing a spreadsheet with a header row to an Access database, you can specify that the first row of data is the headers. The command ‘DoCmd.TransferSpreadsheet’ has an option ‘HasFieldNames’ which, when set to True, tells VBA that the first row of data is the header.
Thx,
JP