It would be nice if you provided the code for the function "GetVariable()", but this is how I would probably write the sub (you had unneeded concatenation-->> & "" & )
Code:
Private Sub cmRiskPresubawardResponses_Click()
Dim pfn As String
Dim q As String
'Check Dates
If Not IsDate(RiskPresubawardResponsesStart) Or _
Not IsDate(RiskPresubawardResponsesEnd) Then
MsgBox "Invalid date(s)."
Exit Sub
End If
q = "Export - RiskPresubawardResponses"
pfn = GetVariable("Risk Presubaward Reports Folder") & "Presubaward Report" & _
Format(gDateStart, "yyyy-mm-dd") & " through " & Format(gDateEnd, "yyyy-mm-dd") & ".xlsx"
DoCmd.OutputTo acOutputQuery, q, acFormat12XLSX, pfn, True
End Sub
Since you have A2016 and you write to an Excel 2016 spreadsheet, you need to use the parameter acFormat12XLSX.
Use acFormatType of "acFormatXLSX" for Excel 2007
Use acFormatType of "acFormat12XLSX" for Excel A2013 and later.
see https://www.accessforums.net/showthr...503#post449503