Solved

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

Posted on 2011-02-23
11
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
11 Comments
 
LVL 10

Expert Comment

by:VTKegan
ID: 34963515
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
ID: 34963641
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
ID: 34963847
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:Bevos
ID: 34963967
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
ID: 34965533

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
 

Author Comment

by:Bevos
ID: 34980097
Thanks so much VTKegan
0
 
LVL 40

Expert Comment

by:als315
ID: 35045180
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
ID: 35053482
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 40

Accepted Solution

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

Author Comment

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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

730 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