Solved

file error: data may have been lost.

Posted on 2009-03-30
6
995 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
[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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

687 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