Solved

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

Posted on 2011-02-23
11
279 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Bevos
  • 5
  • 3
  • 2
11 Comments
 
LVL 10

Expert Comment

by:VTKegan
Comment Utility
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
 

Author Comment

by:Bevos
Comment Utility
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
 
LVL 10

Expert Comment

by:VTKegan
Comment Utility
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
 

Author Comment

by:Bevos
Comment Utility
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
 
LVL 10

Expert Comment

by:VTKegan
Comment Utility

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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:Bevos
Comment Utility
Thanks so much VTKegan
0
 
LVL 39

Expert Comment

by:als315
Comment Utility
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
 

Author Comment

by:Bevos
Comment Utility
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
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
Test this example
Read-pdf.zip
0
 

Author Comment

by:Bevos
Comment Utility
Thanks als315, I changed some of this code and now it works great!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now