Export Report to Excel (1 Viewer)

Wolf

Registered User.
Local time
Today, 15:41
Joined
Oct 24, 2012
Messages
30
Hi,
I would like to export a filtered report to excel.
The report is based on query that has lots of fields, but I use the strwhere to open the report with specific records only.

When I try to use the
DoCmd.OutputTo acOutputReport, "QryTrn", "Excel97-Excel2003Workbook(*.xls)", "", True, "", , acExportQualityScreen
I dont see where I can add my strwhere in this line,
Is it at all possible to export only the filtered data if the filtering is done by VBA and not by the qry itself?
 

Alansidman

AWF VIP
Local time
Today, 14:41
Joined
Jul 31, 2008
Messages
1,493
If you are sending this to an excel file, why not use the query directly? filtered? and use the DoCmd.Transferspreadsheet function instead of building a report. Am I missing something in my understanding of what you are attempting to do?
 

Wolf

Registered User.
Local time
Today, 15:41
Joined
Oct 24, 2012
Messages
30
If you are sending this to an excel file, why not use the query directly? filtered? and use the DoCmd.Transferspreadsheet function instead of building a report. Am I missing something in my understanding of what you are attempting to do?


You would be right if my filters are built on the query, but right now I have no filters on my query, The filters kick in when I open the report, and I want the same filters on my excel export.
 

Wolf

Registered User.
Local time
Today, 15:41
Joined
Oct 24, 2012
Messages
30
Ok I figured it out,
What I did was copied and pasted the entire filter under the export button cmd.
and then by the end
DoCmd.OpenReport "QryMn", acViewReport, , strWhere
DoCmd.OutputTo acOutputReport, "QryMn", "Excel97-Excel2003Workbook(*.xls)", "", True, "", , acExportQualityScreen
 

Alansidman

AWF VIP
Local time
Today, 14:41
Joined
Jul 31, 2008
Messages
1,493
Thanks for the explanation and I am glad that you figured it out.
alan
 

Users who are viewing this thread

Top Bottom