Full context, because this is such an odd problem that I’m not even sure where the issue lies: the database I’m working on requires the storage of consent forms for easy access. I’ve set this up by using code to copy a selected file into a central storage folder (referenced in the global constants), and adding the filename (ConsentProof) to a Short Text field on the Customer table. The Customer form then uses a query to create the full file path (ConsentLink) from the filename and the aforementioned global constants, and displays that.
Here’s the problem: I’ve added a View button which is meant to open the pdf in question.
Private Sub ConsentLink_Click()
On Error GoTo PROC_ERR
Application.FollowHyperlink ConsentLink
PROC_EXIT:Exit Sub
PROC_ERR:MsgBox Err.Description, vbCritical, Me.Name & ".ConsentLink_Click"
Resume PROC_EXIT
End Sub
When the button is clicked, it correctly opens the file – but when focus is returned to Access, it pops up a “Cannot Open Specified File” error.
The bizarre thing is that not only is the error patently untrue, it’s triggering on End Sub. Confirmed that by stepping through the code, and even adding debug print lines to the code, all of which execute. It’s only when it tries to execute End Sub that the error triggers (no associated number), even bypassing On Error Resume Next.
Out of frustration, I tried turning the field displaying the filename into a hyperlink. Identical code to the button, and it works without issue.
I wondered if there was some corruption in place, but Compact and Repair and debugging both make no difference.
While I could just apply the Gordian Knot approach and stick to using the second method, it would be really useful to have any idea what is causing the current issue. Any ideas?