Automated Attaching of pdf documents to databased (matching prefix on pdf to uniqueID in database)

Hello, I have a database with a unique ID called "Call Number"  each call number is five digits such that if starting from 0 you would have "00001".  I also have a folder with several PDF documents with name prefixes matching those of the call number.  My question is does anyone have some example code of how to browse for a pdf directory* (*using the API code here http://www.mvps.org/access/api/api0002.htm) and attach those files to the database records matching the "call number" to the prefix of the PDF file (PDF names are ex. 00001 - Bevo.pdf).

Thanks for any help,
Bevo
BevosAsked:
Who is Participating?
 
als315Connect With a Mentor Commented:
Test this example
Read-pdf.zip
0
 
VTKeganCommented:
Do you actually want to store the attachment in the database using the Attachment Data Type or do you just want to store the path to that file ?
0
 
BevosAuthor Commented:
HI VTKegan, I suppose I would just like to save the file path so that the user can click the attachment filename from Access and open the pdf?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
VTKeganCommented:
I would recommend that as opposed to storing the attachment.  I know that it is included in A2007 and up but, it will greatly increase the file size of the database, and also prevent you from utilizing some of the great features of .mdb in A2003.

With that said:  You want to bring up the Browse for Folder Dialog.  Select a folder, Scan the folder if there is a .pdf file in that folder with a name like 00001.pdf you want to save that file path to a field in a table somewhere where the filename matches a unique ID?

What is the table?  What is the field name?  

Do you want to scan for all records, or do you just want to basically 'Attach' a file path to a specific record?
0
 
BevosAuthor Commented:
Hi VTKegan, so the table will the tblRecordSource and the field [Call Number] will be the unique ID.  Pdf names will be in the form 00000 - <Other Description>.pdf.  The tblRecordSource will also have a field [pdfSource] which will contain the pathname.  My hope is that I can have a link show up on the frmRecordSource which the user can click to simply open the pdf in the 'attached' path.  Is this possible, or do I need to embed the PDF into the form to allow this 'one click' opening of the data?
0
 
VTKeganCommented:

No you do not need to embed the pdf in the form.  It will actually be more clicks if you use the embedded pdf.

I am away from my computer now but will post the solution you need when I get back to it.

I will also post a few example dbs for you to choose the method you like best.  
0
 
BevosAuthor Commented:
Thanks so much VTKegan
0
 
als315Commented:
Here is sample (in author question):
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_26865727.html
It is working.
You don't need browse for file. Generate file name and try to attach it. On error - file is missing.
File name will be like following:
Format([Call Number], "00000") & ".pdf"
0
 
BevosAuthor Commented:
This seems to be a question dealing with outlook and attaching a file with it?  I would like to match a path name for all records in my database based on [Call number] for example such as "Project Directory\PDF\[Call Number] & "some description".pdf".  So I would like to access to use the browse for directory dialogue to choose "Project Directory\PDF\" directory.  Then search that directory for file matches based on a field [Call Number] which will have a 1 to 1 match in the directory (with the exception that the pdf filename will be in the form [call number]_Author.pdf).  So it will have to be a kind of fuzzy match, look at the number before the underscore.  If that isn't possible, I suppose I can just try to make the filename match.  If that was the case, it would just have to be a folder browser setting root directory and then adding .pdf to [call number] in that directory.  Then opening that location.  Any help programming this would be excellent as I am not familiar enough with Access or VBA to do this yet.

Bevo
0
 
BevosAuthor Commented:
Thanks als315, I changed some of this code and now it works great!
0
All Courses

From novice to tech pro — start learning today.