Link to home
Start Free TrialLog in
Avatar of Mark
Mark

asked on

file error: data may have been lost.

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
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Automation of Excel file creation in Access VBA module is my favorite method of building Excel reports.
Avatar of Mark
Mark

ASKER

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

Great!

;-)