cricketbird
Registered User.
- Local time
- Yesterday, 21:36
- Joined
- Jun 17, 2013
- Messages
- 112
All of a sudden, code that just saves a report to PDF, which has been working for years, is throwing a seemingly random error message: "Cannot open specified file".
Thank you!
Running Microsoft 365 MSO (Version 2307 Build 16.0.16626.20198) 64-bit
The code itself is boring:
- The code just saves a PDF to a location on the local C: drive. It doesn't open the report or do anything else.
- The report itself opens just fine in Print Preview within Access, so it isn't a broken hyperlinked object within the report or anything.
- The PDF actually still saves just fine despite this error. It's just an annoying popup to dismiss each time.
- The error handler in my code is NOT generating the displayed error - I put in some dummy text in my code and the actual error produced didn't change
- I haven't changed any code or the report itself in recent memory, so I suspect some recent update with Windows or Access somewhere has changed something. Our install is controlled by corporate and I have no control over updates or versions.
Thank you!
Running Microsoft 365 MSO (Version 2307 Build 16.0.16626.20198) 64-bit
The code itself is boring:
Code:
Private Sub SaveBackupReport_Click()
On Error GoTo MyError
Dim reportName As String
Dim fileName As String
Dim Criteria As String
reportName = "Backup_report"
fileName = "C:\Backups\" & DLookup("[DESCRIPTION]", "[LOCATION TABLE]", "LOCATIONID= " & Me.Combo87) & ".pdf"
Criteria = "[Loc] = " & Me.LOCATIONID
DoCmd.OpenReport reportName, acViewPreview, , Criteria, acHidden
DoCmd.OutputTo acOutputReport, reportName, acFormatPDF, fileName
DoCmd.Close acReport, reportName, acSaveNo
Exit Sub
MyError:
MsgBox Err.Number & Err.DESCRIPTION
Exit Sub
End Sub