You don't need Acrobat; the free Adobe Reader will be enough. To
create the .pdf files, if you don't already have the means of doing
this, you can install one of the many free pdf printer drivers such as
CutePDF Writer from:
http://www.cutepdf.com/
What you need to do is store the path to each .pdf file in a text
field in a row in a table in Access. Also give the table an
autonumber column as its primary key, and you might also want to
include a column such as DocumentType with values such as lyrics,
chords, sheet music etc to identify the type of document in each case.
If you do include a DocumentType column then you should also create a
DocumentTypes table with one column DocumentType. This table will
have one row per type and be related on-to-many to your main Documents
table, making sure that referential integrity and cascade updates are
enforced in the relationship. This protects the integrity of the data
as it ensures that only valid types can be entered in the main
Documents table.
Data entry would in the main be by a form based on the main Documents
table. Never enter data directly into a table in datasheet view,
always via forms. To find a document you'll need some means of
navigating to the correct record in this form. This will depend how
you catalogue your documents, but it can be done either by unbound
controls in the form, or by a separate unbound dialogue form.
To enter the path to a .pdf file in the form you don't need to type it
all in; you can open a dialogue to browse to the file. I normally use
Bill Wilson's class module for this, available from:
http://community.netscape.com/n/pfx...libraryMessages&webtag=ws-msdevapps&tid=22415
The code for a Browse button on the form would be:
On Error GoTo Err_Handler
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.txtPath = strPath
End If
Exit_here:
Exit Sub
Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_here
where txtPdfPath is the name of the control on the form bound to the
text field containing the path.
To open the .pdf file from your form there are a variety of methods
you can use. The simplest s to follow a hyperlink, but I normally
call the Windows API using the following module:
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
Paste the above into a new module and save it as mdlShellExecute say.
You can then call the ShellToFile function from your form with a
button using code like this:
ShellToFile Me.txtPdfPath, Me.Hwnd
All of the above is easy to implement if you have sufficient
experience with Access. You do say you are new to it, however, so I'd
suggest you first take some time to learn a little more about it.
There are plenty of good general purpose books on Access available,
and if you Google 'Access + Tutorial' you should find a number of
online resources to use. Also take some time studying the same
Northwind data base which comes with Access to see how a relational
database is put together in terms of tables and relationships between
them, how the user interfaces with the data via forms and reports, and
how queries are used to bring together data from the various tables as
needed.
Ken Sheridan
Stafford, England