Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output filter datasheet form data to Excel 2

Status
Not open for further replies.

paulnnosh

MIS
Mar 25, 2004
32
Hi Guys,

I have a subform with a datasheet. I use the following line of code to output the data to an Excel spreadsheet.

DoCmd.OutputTo acOutputForm, "subProspects", acFormatXLS, "prospects.xls", True

This copies all data from the subform into Excel. What I would like to do is export only data data that is currently filtered (e.g Only those rows owned by a specific user). However when I filter the data and run the code it still picks up all the records. Is there anyway I can use the outputto method to do this?

Many Thanks
 
have you consider using docmd.transferspreadsheet which can accept select query statements. the select query statements you can 'build' using exisiting form property values.

DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames][, range]

ex: docmd.transferspreadsheet acExport,acSpreadsheetTypeExcel97, "SELECT * FROM " & me.refTosubForm.form.recordsource & " WHERE " & me.refTosubform.form.Filter, name.xls
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top