Transfer Spreadsheet from Query

K

Kennmi

I have a macro that does a TransferSpreadsheet from a Query. In this query,
I have set up CAPTIONS for all the fields. These provide a better
description for the field; one which the users will recognize. When I run
the marco and TransferSpreadsheet occurs, the result is that the columns are
named with the "actual field name" and not the "Caption" that was set up in
the query.

Is there a way to use the TransferSpreadsheet from a query via a macro and
have the CAPTIONS appear as the column headers?
 
K

Ken Snell \(MVP\)

You must use a field alias, not a caption, in order to get the desired field
names in the exported data.

In your query, you set up an alias this way (in the design view, in the
Field cell):

YourNewName: ActualFieldName

In an SQL statement, this shows as
SELECT ActualFieldName AS YourNewName ....

Then export that query to EXCEL.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top