Hyperlink - partially opening

W

Williams

I have a field that is a Hyperlink data type. The field contains the path to
a PDF files. When I click the hyperlink in the table or form view a new
window starts to appear then disappears immediately. Why can't I just click
the window and have the hyperlink automatically appear on my screen? If I
manually go to the directory that stores the PDF I can open the file. Any
suggestions?
 
M

Mark Andrews

I would use the shell function:
Option Compare Database
Option Explicit

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
Public Function OpenDoc(ByVal DocFile As String) As Long
OpenDoc = ShellExecute(0&, vbNullString, DocFile, vbNullString,
vbNullString, vbNormalFocus)
End Function



With some kind of click event to call the code:
Private Sub cmdOpenDirectory_Click()
If (Nz(Me.DocumentDirectory, "") <> "") Then
Call OpenDoc(Me.DocumentDirectory)
Else
MsgBox "You must assign a document directory.", vbOKOnly, "Error"
End If
End Sub


HTH,
 
W

Williams

I am beginning to think that perhaps my problem is related to Adobe. After I
read your post, I thought to myself "why all the code for a hyperlink field".
I thought the purpose of the hyperlink data type was so you could just click
the path and open the file. All of my hyperlinks are to PDF files, so as a
test I did a hyperlink to an different file format & it worked fine. Any
ideas on why other file formats would open in a hyperlink field, but not an
adobe file? As I mentioned previously, I can open the adobe file without a
problem outside of access. But when I click the hyperlink to the adobe file
the window partially appears then disappears.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top