Alter name of Column in a table


I know there are ways to alter the attributes of a column in a table and I have done that.

What I want to do now is from within VBA load the table then alter the names of some of the fields in the table after I know the data that is loaded into them.

I want to export the table to an excel spreadsheet.  When I do that the names of the fields are used as column headers.  I want to chnaae the names of the fields to represent what is in the column so the exported spreadsheet has the correct column names.

Any given experiment will be tested against different materials.  Some experiments may test against only two materials, some may test against 5.


Initial table

ID
Client
Date
Reaction1
Reaction2
Reaction3
Reaction4
Reaction5

Might become
ID
Client
Date
Lead
Water
Iron
Glass
Asbestos
LVL 1
mlcktmguyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
als315Connect With a Mentor Commented:
You can test this example:
 DBExcelExport.mdb
Open form1, correct sub in Form's code (in example files are saved to c:\tmp)
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Use a query to do your export, and you can then "alias" the column names as you wish. For example:

SELECT Col1 AS [First Name], Col2 As [Last Name] FROM YourTable

This would create a query with two columns titled "First Name" and "Last Name", with the data coming from Col1 and Col2 respectively. Save that query, and use that when doing your Export.
0
 
mlcktmguyAuthor Commented:
Exactly what I need with full coding examples
0
All Courses

From novice to tech pro — start learning today.