New error when saving PDF (1 Viewer)

cricketbird

Registered User.
Local time
Today, 13:40
Joined
Jun 17, 2013
Messages
108
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".
  • 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.
Does anyone have any thoughts on what to troubleshoot? Or ways to not have this error pop up for my users?

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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:40
Joined
Oct 29, 2018
Messages
21,553
Are you saying you're getting this error consistently no matter what filename you end up creating?
 

cricketbird

Registered User.
Local time
Today, 13:40
Joined
Jun 17, 2013
Messages
108
Are you saying you're getting this error consistently no matter what filename you end up creating?
Yes - the filenames have not changed and none contain illegal characters.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:40
Joined
Feb 28, 2001
Messages
27,332
Yesterday was Wednesday. Check for having received a Microsoft update Tuesday night because that is their typical update cycle. Some updates have been known to "break" (or at least hinder) code that has been working close to forever. This could also be an Office update since MS bundles up a bunch of "fixes" for each patch cycle. If you find some patches, see if you can look at WHAT they patched. Sometimes you can ask the Windows Update center to roll back a patch to see if that fixes your problem.

When I was working in the U.S. Navy's data center in New Orleans, we used to positively dread coming in on Wednesday morning in abject fear of discovering yet ANOTHER "helpful" patch promulgated by MS that would make our lives difficult.
 

cricketbird

Registered User.
Local time
Today, 13:40
Joined
Jun 17, 2013
Messages
108
Yesterday was Wednesday. Check for having received a Microsoft update Tuesday night because that is their typical update cycle. Some updates have been known to "break" (or at least hinder) code that has been working close to forever. This could also be an Office update since MS bundles up a bunch of "fixes" for each patch cycle. If you find some patches, see if you can look at WHAT they patched. Sometimes you can ask the Windows Update center to roll back a patch to see if that fixes your problem.

When I was working in the U.S. Navy's data center in New Orleans, we used to positively dread coming in on Wednesday morning in abject fear of discovering yet ANOTHER "helpful" patch promulgated by MS that would make our lives difficult.
I have no control over our updates and versions, including no ability to roll back patches, unfortunately.

Any ideas how to stop the popup?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 18:40
Joined
Sep 12, 2006
Messages
15,718
I would put a break in your code, and step through it. Are you seeing an error code. If not it's not your error handler firing.
If it is showing an error code, maybe it's not happening on the line you think. Any error will just end your subroutine.

Maybe the filename already exists, maybe the disk is full even, maybe the filename is invalid, maybe there's a permissions error. Maybe [description] is null for combo87.

In the filename construction you are using combo87, but in the criteria on the next line you are using LOCATIONID. 2 different values?
 
Last edited:

cricketbird

Registered User.
Local time
Today, 13:40
Joined
Jun 17, 2013
Messages
108
Thanks everyone - IT wouldn't roll back to an earlier version of Access, but they would bump us up a release, and the issue seems to have resolved. I never got an errors to show up in the various places one sees errors, so I think it might have been more OS-level errors that I have no ability to troubleshoot (yay corporate environment). At any rate, it is working now. Thank you!
 

Users who are viewing this thread

Top Bottom