Solved

file error: data may have been lost.

Posted on 2009-03-30
6
981 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
Comment Utility
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
Comment Utility
Automation of Excel file creation in Access VBA module is my favorite method of building Excel reports.
0
 
LVL 1

Author Comment

by:jmarkfoley
Comment Utility
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
Comment Utility
Great!

;-)
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
:-O
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

772 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

9 Experts available now in Live!

Get 1:1 Help Now