wilcon
asked on
Exporting Data a Microsoft Access from a subform to Excel
I have a search form with a subform on it. I want to export the results from the subform to Microsoft excel. The subform is displayed as a datasheet. I am using the DoCmd.OutputTo acOutputForm, "subDepositions2", acFormatXLS command but it is not exporting the data that is displayed in the subform from the search results but the underlying query of the subform. Can anybody help me with this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi
How have you linked the form and the sub form? If you are using the Master and Child properties then these will not be passed to the function.
I would suggest that you create a Select query and pass the filter parameters from the main form to this and then use this query as the data source for the export.
ie QueryABC :Select "*" From subDepositions2 where subDepositions2.field1 = form.filter1 and subDepositions2.field2 = form.filter2
DoCmd.OutputTo acOutputForm, "querty ABC", acFormatXLS
Try this.
Rohit
How have you linked the form and the sub form? If you are using the Master and Child properties then these will not be passed to the function.
I would suggest that you create a Select query and pass the filter parameters from the main form to this and then use this query as the data source for the export.
ie QueryABC :Select "*" From subDepositions2 where subDepositions2.field1 = form.filter1 and subDepositions2.field2 = form.filter2
DoCmd.OutputTo acOutputForm, "querty ABC", acFormatXLS
Try this.
Rohit
ASKER
thank you very much harfang.
Welcome! Glad you liked it.
(°v°)
(°v°)
so the command is working properly.
if you want to export the same design and data, then you can do a Report, and export the Report, using the same query of the subform.
jaffer