This tutorial is going to show you how to export a MS Access query or a subform to Microsoft Access using VBA code. Too export subform or query, we can use DoCmd.OutputTo method. Its a pretty simple code to get the query exported to Excel and it will automatically opened in Excel after the export process is completed.
Here is the code:
DoCmd.OutputTo acOutputQuery, "Q_Export_DHAssay to excel", acFormatXLS, "E:\test.xls", True
Change the Q_Export_DHAssay to excel” with your query. E:\test.xls is the output file.