The most efficient way is to store the path to the .pdf file in a field. You
can use a hyperlink field for this, so that clicking on the hyperlink opens
the .pdf file. The .pdf file must be in a shared folder accessible to the
relevant users of course.
Alternatively you can store the path as a string in a text field and open it
with some code (this could be in the Click event of a separate button on the
form, or the DblClick event of the text box bound to the field. There are
various ways of doing the latter, but I generally call the Windows API. To
do this add the following module to your database:
''''module begins''''
Option Compare Database
Option Explicit
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 nshowcm As Long)
Sub ShellToFile(strPath As String, ByVal lngHwnd As Long)
Dim lngRetVal As Long
lngRetVal = ShellExecute(lngHwnd, "open", strPath, _
vbNullString, CurDir, 1)
If lngRetVal < 32 Then
MsgBox "Unable to open file " & strPath, vbInformation, "Warning"
End If
End Sub
''''module ends''''
Save the module as something like mdlShellExecute. You'd then call it in
the form with the following code:
ShellToFile Me.FilePath hwnd
where FilePath is the text field in which the paths are stored.
To insert the path into the field you can browse to the file with a common
dialogue. I use Bill Wilson's class module for this which you can obtain
from:
http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=22415&webtag=ws-msdevapps
Download Bill's file, Unzip it and add the BrowseForFileClass class module
to your database. In the form call it, from an 'Add PDF File' button's Click
event procedure say, with:
Dim OpenDlg As New BrowseForFileClass
Dim strPath As String
OpenDlg.DialogTitle = "Select File"
OpenDlg.AdditionalTypes = "PDF Files (*.pdf) |*.pdf"
strPath = OpenDlg.GetFileSpec
Set OpenDlg = Nothing
If Len(strPath) > 0 Then
Me.FilePath = strPath
End If
Ken Sheridan
Stafford, England