I have written a below mentioned code which export the Query into a Excel file.
Public Function exportToXl11() Dim dbs As DAO.Database Set dbs = CurrentDb Dim sFilename As String sFilename = "c:\ExportFile\Output_Results.xlsx" DoCmd.OutputTo acOutputQuery, "metrics2", acFormatXLSX, sFilename, Autostart:=False End Function I have another table name "Date1" which have date. I want a code which will export the query with a date given in a "Date1" table. Like the output will be "Output_results_23-05-2020.xlsx" instead of "Output_Results.xlsx"