Hello
On 03-25-2017 sneuberg gently helped me with above code.
With this code I export a query to excel. If for example I search by day1 20_02_2018 and day2 20_02_2018 the code assign the exported file name as 20_02_2018_qry_01.
I need the code to include in the exported file name the plot code such: 20_02_2018_qry_01_6
On the other hand, when a user enters to dates and plot code such as:
Day1 05/02/2018 and Day2 20/02/2018 and plot 2
In the exported query I need the file name as: 05_02_2018- 20_02_2018_2.
I really appreciated your help
On 03-25-2017 sneuberg gently helped me with above code.
With this code I export a query to excel. If for example I search by day1 20_02_2018 and day2 20_02_2018 the code assign the exported file name as 20_02_2018_qry_01.
I need the code to include in the exported file name the plot code such: 20_02_2018_qry_01_6
On the other hand, when a user enters to dates and plot code such as:
Day1 05/02/2018 and Day2 20/02/2018 and plot 2
In the exported query I need the file name as: 05_02_2018- 20_02_2018_2.
I really appreciated your help

Code:
Private Sub cmb_export_excel_bydatesrange_plot_Click()
Dim filename1 As String
If DCount("*", "qry_01") <> 0 Then
filename1 = "C:\Path\" & Replace(Me.txtday1, "/", "_") & "_qry_01.xlsx"
DoCmd.OutputTo acOutputQuery, "qry_01", acFormatXLSX, filename1, False
MsgBox "Query already exported to Excel"
Else
MsgBox "This range has no records"
DoCmd.Close acQuery, "qry_01"
End If
End Sub