Solved

transfer to excel

Posted on 2006-10-31
11
1,206 Views
Last Modified: 2011-10-03
Hi.  I need to transfer one of reports from my database to Excel file and transfer should be automatically.
I have following code
DoCmd.OpenReport ("xxx"), acViewPreview

---this line allows to print the report

DoCmd.OutputTo acOutputReport, "xxx", acFormatXLS, "issue.xls", True

---second line of code should transfer report xxx to excel file issue. xls or at least any xls file

Code has an error.  Please help
0
Comment
Question by:maximyshka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 17847091
Try no parentheses in the first line:

DoCmd.OpenReport "xxx", acViewPreview

The second line looks syntactically correct.  What is the error message?
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 140 total points
ID: 17847133
include a path for the excel file

DoCmd.OpenReport "xxx", acViewPreview

DoCmd.OutputTo acOutputReport, "xxx", acFormatXLS, "C:\issue.xls", True
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17847213
Both of those lines work fine exactly as you have them posted in an Acc. 2003 sample.  The Excel file gets written to the current directory if no path is specified.  Verify the following:

1.) The exact error message and line of code causing the problem.  Set Break On All Errors if needed.  It it possible that the code causing the error is somewhere else (the report's Load, Activate, Open events for example)?
2.) Double check the name of your report.
3.) Make sure that  Issue.xls is NOT open at the time you run the code.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:maximyshka
ID: 17849760
Thanks a lot.

Second problem, after I open Excel file I got on Excel file only query headings not actual data from the report.  How to fix that problem?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17850013
That's weird.  I had something similar happen in one of my databases exporting a report (problem with how he report format exported to excel).  It turned out that the data was there, just not visible because the text and cell background color somehow wound up the same in the Excel file (even though it looked good in the original report).  Check into that...

0
 

Author Comment

by:maximyshka
ID: 17852271
Hello guys.  Problem is not fixed.  I can't export any kind of reports to Excel.  Data is not visible.
Any suggestions???

I'm looking on property of my reports.  Everything seems to be the same.  However, in one report data is transferred to Excel, in other reports not.
0
 

Author Comment

by:maximyshka
ID: 17852338
Disregard previous comment.  Problem was that detail section of the report was not visible.  I need that for display and printing purposes only summary data (everything that I have in footer).  Is there any way to transfer summary data in Excel file???

Problem: data transfered to Excel file only if detail section of the report is visible
0
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 180 total points
ID: 17853144
Exporting any Access report to Excel would mean losing the cosmetic formatting of the Access report, and will be extremely ugly.

If all you want to do is transfer the data, then do it using DoCmd.TransferSpreadsheet and use the table/query name that feeds the report, and not the report.

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel97, "Your table or query name here", "Your Excel spreadsheet name here.xls",,"Your Excel tab or named range here, or blank"

{substitute acSpreadsheetTypeExcel97 with whatever is appropriate for your version of Excel}
0
 

Author Comment

by:maximyshka
ID: 17853736
Jimborn, I have an Access form.  By clicking the button I want to have two actions:
1) preview report for printing
2) transfer report to excel file

Everything would work if my report has detail section visible
However, I need only summary (footer report), not detail section.  Like number of loans, average value for several years, breaked by months.  

Since I don't have detail section and have only summary
DoCmd.OutputTo acOutputReport, "xxx", acFormatXLS, "issue.xls", True not displaying data in excel file

DoCmd.TransferSpreadsheet method is good only to transfer data from query or table but not from the report

Any suggestions?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 180 total points
ID: 17854736
>However, I need only summary (footer report), not detail section.  Like number of loans, average value for several years, breaked by months.  
If you only need the summary data...

How about using a seperate query to collect summary data such as that shown in your report.  Use aggregate functions like this:

SELECT Count(Loans) as CountOfLoans, Avg(LoanValue) as AvgValue, MonthName
FROM qryYourReportsRecordsource
Group By MonthName

Then export the data using the transferSpreadsheet command like Jim suggested
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17870681
Glad to help :-)
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question