How do I link and open a PDF file with a primary key field via a button

Field

New member
Local time
Today, 15:01
Joined
Jan 13, 2009
Messages
3
Hello to everyone, this is my first post here.
:confused:
I am new at this, so here is my scenario. I am working on a small access 2007 database to search and keep track of our business forms about 300 or so and some forms has between 2 to 10 pages. All forms were converted to PDF for better security and accessibility. All forms are saved using a form code, for example "fc1000, fc1001" and so on. I also have a jpeg snapshot of each form attached to each record, so the user can visually see how the form looks like.

I need help on the following:
Search and Print a specific pdf form

How do I link and open a PDF file with a primary key field via a button? I know that I need some VBA code. I looked and search everywhere but without luck.

Primary field: formCode, will stored the pdf file name which is "fc1000, fc1001, etc"

Primary key field
formCode
fc1000
fc1001
fc1002

C:\Forms\”.pdf“
Form name
fc1000
fc1001
fc1002


Thanks in advanced
 
A couple of things that might get you started

http://allenbrowne.com/ser-59.html On that site is a way to enable you to get file names into an Access table. I have a feeling that 200 is the most it will do from a folder. So might need to split your files into two folders to get going.

Place a button on a conntinuous form and for OnClick put

Forms!ln!Command5.HyperlinkAddress = ("C:\StoreLetters\" & Format([Forms]![ln]![LNameNoDoc]) + ".pdf")

i copied that from what I use so you obviously need to change form and textbox name. What that does is to use the file name that is in a textbox on the record. So if the file name was MyAccounts and MyAccounts was in the folder StoreLetters then clicking would insert the hyperlink address and then open the file.

The reason for the + ".pdf") at the end is because I have the file name stored without the extension.

I think you could also use Shell to open the PDF and probably have it reference a textbox to get the file name.

I don't know how to open and print a PDF if one go. Hyperlink or Shell will be no good as they just open the file and I don't know how to open a PDF with VBA from Access in the same manner as is done for Word, which allows Word to be printed.
 
Hello Mike375,

Thank you for your quick reply.

The code in that site looks a little to complicated to me since I am new to this, I'll give it a try.

I will post the results later.

Thanks again
 
Hello Mike375,


The code in that site looks a little to complicated to me since I am new to this, I'll give it a try.


Thanks again

The you won't like what I found that prints PDF documenst from Access:)
 
Hello Mike375,

Thank you for your quick reply.

The VB code on that site looks a little to complicated to me since I am new to this, I'll give it a try.

I will post the results later.

Thanks again
 
Is there any chance you could post what you found? Please ;)

I have attached a DB with just a module that has it.

Put this behind a button, stand alone label or textbox

Call PrintPDF("C:\Letters\Letter.pdf") and obviously your folder/files

Ideally, use AllenBrowne' function to get file names into Access and then format your reference to the file in a similar manner to what I posted above with the hyperlink address.
 

Attachments

I have attached a DB with just a module that has it.

Put this behind a button, stand alone label or textbox

Call PrintPDF("C:\Letters\Letter.pdf") and obviously your folder/files

Ideally, use AllenBrowne' function to get file names into Access and then format your reference to the file in a similar manner to what I posted above with the hyperlink address.

Thank you!

I have a client that often needs to reprint several, sometime hundreds of pdf files. As they all have their file location stored in a database and this should help greatly. Now I just hope they use Adobe to print their pdfs!
 

Users who are viewing this thread

Back
Top Bottom