Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export crosstab with grouping to Excel

Status
Not open for further replies.

MePenguin

Technical User
Oct 31, 2003
107
0
0
SE
I have a problem getting a report based on a crosstab query to export to Excel in the format my users would like. (They want to click a button from report preview... got the button, but...)

The query is created on demand in VBA (columns are dynamic), and the report will be eventually if I can get the export to work properly.

It exports fine to Word (using the OfficeLinks export button), exporting identical to the Access preview:
report_export_word.gif


but when I use the OfficeLink button to export to Excel it seems to use the query's layout and not the report's... sort of:
report_export_excel.gif

(I've long since stopped wondering about the order of columns in Access!)

I'm assuming that this is a 'feature, not a bug', but it's not what I want. Notice that it's the grouping that's giving me trouble. The sort order is the hidden column CODE.

If I copy & past the Word export into Excel & get almost what I want, but the tabs through missing data cause problems:
report_export_word_paste_in_excel.gif

(I suppose I could get around the latter by IIf'ing zero's into the null values, but i'd prefer not to)

Any ideas/workarounds?

I'm tempted to do forget trying to export the report and use VBA to dump the data directly into Excel cells... but seems like a lot of work if there is an easier solution.

Here's the Crosstab's SQL, if it's of any help (the PIVOT columns will change each time):
Code:
TRANSFORM Max(TempAbundForSite.Abundance) AS MaxOfAbundance
SELECT TempAbundForSite.CODE, INDEX.FAMILY, TempAbundForSite.SpeciesName, Sum(TempAbundForSite.Abundance) AS [Total Of Abundance]
FROM TempAbundForSite INNER JOIN [INDEX] ON TempAbundForSite.CODE = INDEX.CODE
GROUP BY TempAbundForSite.CODE, INDEX.FAMILY, TempAbundForSite.SpeciesName
ORDER BY TempAbundForSite.CODE
PIVOT TempAbundForSite.RefNrContext In ('S1','S2');

Thanks in advance,

Phil

---------------
Pass me the ether.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top