• A button to export to Excel (Access 2016)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » A button to export to Excel (Access 2016)

    • This topic has 0 replies, 1 voice, and was last updated 8 years ago.
    Author
    Topic
    #1772761

    Greetings,

    I created a form whereby users answer to parameter values and press ‘Run Query” and pass those parameter values to a report.
    I used the following for ‘Run Query’ button:

    Code:
    DoCmd.OpenReport “MrReportName”, acViewPreview
    

    The above works fine. What I’m trying to achieve is the following:
    Once users previewed the filtered data, I want them to be able to export the result to excel. To achieve this, I created another button ‘Export’ and use the following syntax:

    Code:
    DoCmd.OutputTo acOutputQuery, “MyQueryName “, acFormatXLS, , True
    

    The above works well. The problem is that it doesn’t reflect the filtered data (the report displays everything).
    I also attempted to use the built-in export to excel wizard for the command button, but I did not see any option to export data to excel.

    TIA,

    Reply To: A button to export to Excel (Access 2016)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: