Forum Discussion
Getting Run Time Error 2302 Access can't save output to file you've selected
The Run-Time Error 2302 in Access usually occurs when the application cannot save the output to the specified location or file for several potential reasons. Here are some common causes and troubleshooting steps you can use to resolve this issue.
The output location path (strFullPathMatches and strFullPathNoMatches) you are using is incorrect, inaccessible, or doesn't include a file name with an appropriate extension.
Ensure that the path includes a valid file name and extension (e.g., .xls or .xlsx).
To resolve this, you need to add a file name and extension to the paths like these:
strFullPathMatches = "I:\Customer Operations-Core\Operational QA\Dispute Services Verification\2025 DPP Verification\CorrespondenceMatches.xlsx"
strFullPathNoMatches = "I:\Customer Operations-Core\Operational QA\Dispute Services Verification\2025 DPP Verification\CorrespondenceNoMatches.xlsx"
Please have in mind that Windows has a maximum path length limitation (260 characters). If your path is too long, Access may fail to save the file.
Here's a revised version (a example) of your code with debugging messages to help identify the problem:
Private Sub Command230_Click()
' Define output location variables
Dim strFullPathMatches As String
Dim strFullPathNoMatches As String
strFullPathMatches = "I:\Customer Operations-Core\Operational QA\Dispute Services Verification\2025 DPP Verification\CorrespondenceMatches.xlsx"
strFullPathNoMatches = "I:\Customer Operations-Core\Operational QA\Dispute Services Verification\2025 DPP Verification\CorrespondenceNoMatches.xlsx"
Me.Dirty = False
' Debugging messages to verify paths
Debug.Print "Saving to: " & strFullPathMatches
Debug.Print "Saving to: " & strFullPathNoMatches
' Run queries and output to Excel
On Error GoTo ErrorHandler
DoCmd.OutputTo acOutputQuery, "QryCorrespondenceMatches", acFormatXLSX, strFullPathMatches, True
DoCmd.OutputTo acOutputQuery, "QryCorrespondenceNoMatches", acFormatXLSX, strFullPathNoMatches, True
' Run delete queries to clear out the MS Access tables
DoCmd.OpenQuery "QryDeleteLetterStatusRecs"
DoCmd.OpenQuery "QryDeleteCorrespondenceRecs"
MsgBox "Export completed successfully!", vbInformation
Exit Sub
ErrorHandler:
MsgBox "Error: " & Err.Number & " - " & Err.Description, vbCritical
End SubHope this information can help you a little with your plans...if not, please just ignore it.