Solved

file error: data may have been lost.

Posted on 2009-03-30
6
987 Views
Last Modified: 2013-11-28
I have a report with 6 total fields in the report footer. The report prints fine on preview or print to rtf. However, when I print to xls, then try opening the spreadsheet I get the message "file error: data may have been lost.", and the 6th total field on the report is missing. I've tried everything I can think of including symplifying this field down to a constant (control source =2), adding a 7th field, Nothing works. The field always shows up on the rtf output, but get nothing beyond the 5th report footer field with xls output. Any ideas?
MS Access 2003, XP
0
Comment
Question by:jmarkfoley
  • 3
6 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 24025123
jmarkfoley,

Exporting Reports to XLS has never been, and will never be, ....perfect.
This feature is not even available in Access 2007 anymore.

What most people do is simply output the Report's Recordsource to Excel.
Then do the totals in Excel.
Thus avoiding this entire issue.:
    DoCmd.TransferSpreadsheet acExport, , "YourTableOrQueryName", "C:\YourFolder\YourFile.xls", True

There are some steps you can take to tweak the report for the best import into Excel.
See the Help file on the:  OutputTo Action

In none of this works for you then you could try posting a sample of this most uncooperative database here.

JeffCoachman
0
 
LVL 18

Expert Comment

by:jmoss111
ID: 24026542
Automation of Excel file creation in Access VBA module is my favorite method of building Excel reports.
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 24039356
boag2000 - I've taken your advice to heart and implemented your DoCmd.TransferSpreadsheet solution. The "YourTableOrQueryName" part really is only a table name or query. A stored procedure (which is what I have) will not work here. My solution was to simply insert the results of a stored procedure into a table, then run the DoCmd.TransferSpreadsheet. Works fine.

I also went ahead and opened the spreadsheet from the VB form using the code below.

Thanks.
    Dim oApp As Object
 
    Set oApp = CreateObject("Excel.Application")
    oApp.Visible = True
    On Error Resume Next
    oApp.UserControl = True
    oApp.Workbooks.Open ("C:\YourFolder\YourFile.xls")

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24040165
Great!

;-)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 24044071
:-O
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now