Export subform results to Excel

J

jimster68

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
subform?

Thanks,
Jim
 
J

jimster68

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.
 
Joined
Sep 15, 2011
Messages
8
Reaction score
0
A2EE.mda is a tool that exports records from subform or subdatasheet to Excel

Hi,
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:
limbersti.cz/A2EE/
Let us know it it helped.
BR
Norbert
 
N

Norbert Limbersky

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:
http://www.limbersti.cz/A2EE/

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.

BR

Norbert
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top