Solved

file error: data may have been lost.

Posted on 2009-03-30
6
991 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

763 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