views:

36

answers:

1

I have a project in Access 97 that I have to add the ability to export a report to excel. When you run the report within the program there is already the ability to export to word and to excel though the excel only some of the headers.

Through research I found that I might be able to get it to work using OutputTo but unfortuneately I can't attempt this because I am unable to find the code for the toolbar in the report view. I found the actual report. I have never used Access of any version so do I just need to add a macro or do I have to approach this a different way? I can't find where the code is already located.

+1  A: 

either use a macro with the TransferSpreadsheet action, or export it with VBA code like this:

    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, sQryExport, sPath & "\xls\" & sPrefix & sRptGroup & ".xls"

    DoCmd.OpenReport "rpt_summary", acViewPreview, , "reportGroupID='" & sRptGroup & "'", acHidden
    DoCmd.OutputTo acOutputReport, "rpt_summary", "Rich Text Format (*.rtf)", sPath & "\rtf\" & sPrefix & sRptGroup & ".rtf"
    DoCmd.Close acReport, "rpt_summary"
Beth
How does it know to do this when the export button is pressed. Is there extra code I need to put?
Kyra
it doesn't. you have to tell it. if you create an export button, have the button click event call the macro or embed the VBA code in a function and have the button call that.
Beth