Export subform results to Excel

Discussion in 'Access Forms Coding' started by jimster68, Mar 6, 2007.

  1. jimster68

    jimster68 Guest

    I have built a main form that includes controls to filter/search records from
    a subform based on a query. The query pulls data from multiple tables. I
    want to create another command button in the main form to export the filtered
    results from the subform to an excel spreadsheet. I have the following code
    but it pulls all of the data from the query, not the filtered results.

    Private Sub cmdExcel_Click()
    DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
    "q_Server_Data", "c:\temp\test1.xls"

    End sub

    How can I change this to include only the data from the filter/search in the

    jimster68, Mar 6, 2007
    1. Advertisements

  2. jimster68

    jimster68 Guest

    Well I discovered something that works.

    DoCmd.OutputTo acOutputForm, "frm_Server_Data", acFormatXLS, _
    strPath & "\ServerData.xls" ', AutoStart:=-1

    This outputs the filtered results from the subform to the spreadsheet.
    jimster68, Mar 9, 2007
    1. Advertisements

  3. jimster68


    Sep 15, 2011
    Likes Received:
    Prague, The Czech Republic
    A2EE.mda is a tool that exports records from subform or subdatasheet to Excel

    I think you will be able to export filtered subform's records to the Excel with A2EE.mda which is an Access add-in specially developed for such tasks.
    You will find more on:
    Let us know it it helped.
    Norbert, Jun 6, 2012
  4. DoCmd.TransferSpreadsheet method will always export all data of underlying table or query, not only the filtered data.

    When you want to export only filtered data, you need to use Access add-in 'A2EE.mda' that can be found here:

    In it's settings you can for example setup that all subdatasheet's records related to current record of master table / query / form will be exported to Excel.

    Which is exactly what you look for.


    Norbert Limbersky, Jun 25, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.