
June 23rd, 2006, 04:17 AM
|
|
Registered User
|
|
Join Date: May 2006
Posts: 9
Time spent in forums: 1 h 45 m 21 sec
Reputation Power: 0
|
|
|
Export Subform to Excel
Hi all,
I am trying to to export the data shown in a subform to excel when pushing an export button. On the main form I have 4 combos that filter the subform (can be selected in any order) by querying the table based on the values in the combos.
I have seen a few examples that can determine the record source of the subform and export the data from that but it doesnt seem to be working. That would the best option if anyone knew how to do it.
The other option I have been trying is i have a Public variable strSQLExport which gets cleared and then written to at each selection and has the sql query ready to be called when the button is pushed. I have used a message box and if nothing is selected i have the default query as Select * from tablename
and then the following line to export
DoCmd.OutputTo acOutputQuery, strSQLExport, acFormatXLS, "Export.xls", True
I get Runtime error 3011 - The MS jet engine dB could not find the object 'Select * from tablename'. Make sure the object exists and that you spell its name and path correctly.
Any ideas?
|