Solved Custom column names on export to excel? (1 Viewer)

mamradzelvy

Member
Local time
Today, 05:20
Joined
Apr 14, 2020
Messages
145
Hi, is it possible to have my query pull data from the db and put it under new custom column names for the excel export?
I have a db with shortcuts which are not exactly pleasant to look at by anybody but me and i would like to be able to export these under diferent names without actually hard modifying the column names in the table.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 11:20
Joined
May 7, 2009
Messages
19,231
create a Query and Alias the Column into something else.
import this query to excel, eg:

SELECT ID AS Ident, ProdID AS ItemCode, UnitPrice AS Price, etc.... FROM table1
 

deletedT

Guest
Local time
Today, 04:20
Joined
Feb 2, 2019
Messages
1,218
In Excel If you're using a Pivot table, you can change the field name:

2020-05-15_16-05-48.jpg
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 04:20
Joined
Jul 9, 2003
Messages
16,271
without actually hard modifying the column names in the table.

I think you have the answer already, however your question reminded me of a product I built last year which extracts a forms control names, the captions from the associated labels and the underlying field name for each control. You can then use them as column names in Excel.

I'm thinking that if your table is used in a form then it is likely that you have a button on your form for running the query. You could use code to extract the actual names from the controls labels. This extra coding required would only be desirable/necessary if you were making something that you wanted to use in many different forms.

In my code, different versions of the control names are stored in a listbox and then the information is extracted from the list box and passed through to Bob's code with some code I found here:-


The main component for this process was some code written by Bob Larson which you can find on this website here:-

 

Users who are viewing this thread

Top Bottom