?
Solved

file error: data may have been lost.

Posted on 2009-03-30
6
Medium Priority
?
1,005 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
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 …
Suggested Courses

765 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