none
Export Access report to Excel RRS feed

  • Question

  • Hi all,

    I have a database in Access 2013 where I export an Access report to MS Excel. Code as follows:

            DoCmd.OpenReport "ReOrderTableReport", acViewPreview, "", "", acHidden
            DoCmd.OutputTo acOutputReport, "ReOrderTableReport", acFormatXLS, "c:\temp\ReOrder.xls"
            DoCmd.Close acReport, "ReOrderTableReport"
    

    The Access report that is opened, is fine. It looks as follows:

    Note the location of the "Stock Code" and "Description" fields. Now it is exported to Excel.

    The Excell sheet looks as follows:

    The "StkCode" field and "Descr" fields has moved around. Some other fields has also moved around.

    I need the Excel sheet to be in the same order as the Access report. Is there any way I can force the Access report to export exactly as per the Access report to Excel?

    Much appreciated

    Deon

    Wednesday, August 14, 2019 7:00 AM

Answers

  • Hi Deon

    The report is based on a query? Please try to Export the query instead.


    Cheers // Peter Forss Stockholm

    • Marked as answer by Deon SA Wednesday, August 14, 2019 12:26 PM
    Wednesday, August 14, 2019 7:10 AM

All replies

  • Hi Deon

    The report is based on a query? Please try to Export the query instead.


    Cheers // Peter Forss Stockholm

    • Marked as answer by Deon SA Wednesday, August 14, 2019 12:26 PM
    Wednesday, August 14, 2019 7:10 AM
  • Hi,

    Further input, use a new query instead.

    DoCmd.OutputTo acOutputQuery, "YourNewQueryNameHere", acFormatXLS, "c:\temp\ReOrder.xls"

    DoCmd.Close acQuery, "YourNewQueryNameHere"

    This way you can edit your query according to your needs. You don't have to modify your Report. You don't need to Open or run your Query or Report.


    • Edited by AccessVandal Wednesday, August 14, 2019 7:29 AM typo
    Wednesday, August 14, 2019 7:28 AM
  • Thanks guys - exporting the query solved the issue.

    Wednesday, August 14, 2019 12:26 PM