Export subform results to Excel

G

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

Thanks,
Jim
 
G

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.
 

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