Why when PDF file opens it won't stay on top

I have a hyperlink field on a form that when clicked opens the PDF file that is in the text field.

The PDF file opens for display just fine but doesn't stay on top.  The Access form stays on top.  Can this be resolved so the PDF stays visible and not behind the Access form?

Here is the onclick code:

Private Sub txtFileName_Click()
On Error GoTo Err_txtFileName_Click

    Application.FollowHyperlink Me.txtFileName

Exit_txtFileName_Click:
    Exit Sub

Err_txtFileName_Click:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
    Resume Exit_txtFileName_Click

End Sub

Open in new window

SteveL13Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zalazarCommented:
You could try to add an extra parameter to open the document in a new window via:
Application.FollowHyperlink Me.txtFileName, , True
The default is to open the document in the current window.

Another option might be to use ShellExecute.
Please place outside the Sub
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
  As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Open in new window

Then
vRet = ShellExecute(Application.hWnd, "Open", Me.txtFileName, "", "C:\", 1)

Open in new window

I can't verify unfortunately but it might be that Application.hWnd maybe has to be replaced with Application.hWndAccessApp in your code.
SteveL13Author Commented:
I tried this but get the same result:

Application.FollowHyperlink Me.txtFileName, , True


But I don't know what you mean by "put this outside the sub":

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
  As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Open in new window

zalazarCommented:
Thanks for your feedback.
I actually meant that you can put the "Private Declare Function" above the sub or on the first line of the VBA code.

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation _
  As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub txtFileName_Click()
On Error GoTo Err_txtFileName_Click

    vRet = ShellExecute(Application.hWnd, "Open", Me.txtFileName, "", "C:\", 1)

Exit_txtFileName_Click:
    Exit Sub

Err_txtFileName_Click:
    MsgBox "Error Number: " & Err.Number & vbCrLf & "Error Description: " & Err.Description & vbCrLf & "Error Source: " & Err.Source
    Resume Exit_txtFileName_Click

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.