PDA

View Full Version : Adding PDF's to table...



BexleyManor
04-22-2006, 12:26 PM
Ok, I have a user form thats used to add data to a table (obviously!) but I have been asked is it possible to be able to attach a PDF file via the user form so that it is also added to the table??

Hope you can help as it's driving me :banghead:

stanl
04-22-2006, 01:25 PM
Not really sure what you are asking. But if you mean have a field in your table that can contain a PDF file, the answer is yes. Define the field as a binary/OLE Object and use an ADODB.Stream Object to insert a selected PDF into the field. If you mean be able to display the PDF within an Access form, I'm not so sure - probably requires full version of Adobe, whereas with the other method you can just export out of the field to a file and use ShellExecute().

.02
Stan

BexleyManor
04-22-2006, 02:59 PM
Hi Stan,

I'm not particulary wanting to view the PDF in the user form, I can do that with a report, what I would like is to have something on the user form to enable me to add a PDF to a table field as easily as a text box allows me to add text to a field.

You mentioned, ADODB.Stream Object to insert a selected PDF into the field, could you expand on this please?

Does that make anymore sense?? I hope so !! Sorry my previous ramble didn't!!

stanl
04-23-2006, 10:15 AM
I'm not particulary wanting to view the PDF in the user form, I can do that with a report,

Either way, you're talking about an embedded link, whereas the Stream will insert the entire PDF document as Binary. However, I use Streams a lot and normally include a 'Button' on my form which says "Click To Add" [PDF/XLS/XML/JPEG... whatever] - then I process the click event by popping up the Windows common control with a filemask, verify a file selected then something like



'assume file selected is cPDF
'assume Access Field is Binary/OLE type named MyPDF
S = CreateObject("ADODB.Stream")
S.Type = 1 'binary stream
S.Open()
S.LoadFromFile(cPDF)
oRS.Fields("MyPDF").Value = S.Read(-1)
S.Close()


But I am still confused over how you want the file stored as opposed to how it is displayed. :mkay Stan

boneKrusher
05-06-2006, 06:25 AM
I never embed files. I grab the file and save the link to a table. I use the PDF activeX control to them load the file. If this is what you want to do, let me know and I'll help.

Bones

BexleyManor
06-01-2006, 03:45 PM
Hi Bones, I got dragged away on something else in the office so this is my first chance back at this topic.

Yes, what you suggest sound interesting and I presume less 'database swelling' than piling them into a table.

I'd love to hear what you suggest, sounds very interesting.

boneKrusher
06-02-2006, 04:45 PM
I'll put together a sample for you. Giveme a day or two ok.

Bones

boneKrusher
06-02-2006, 05:06 PM
make a folder call "images" in the same folder where the database is.

take a look a this. Any question, just ask.