PDA

View Full Version : Attach a .jpg file to a record



sburgess
11-06-2008, 08:58 AM
Is there a way using VBA, to be able to click a button, and have the code search a directory for a .jpg file, based on criteria, and then attach it to a record in a form?

I don't even know where to begin with this one, so any help would be great!!

Thanks!

:dunno

nepotist
11-06-2008, 09:24 AM
It is quite easy. I have attached a sample with this. This database is developed using Office 2007 and tried to save it in o3 but it did not allow me to do it.
You need to have one filed as attachment type. and when you create a form that should work automatically

sburgess
11-06-2008, 09:32 AM
Unfortunately, I have Access 2003, so it will not let me open the file to view. :(

nepotist
11-06-2008, 09:36 AM
I am sorry I started learning access with 07 .. so no clue about it in 03
I am some one would be here with an answer for you .. good luck

sburgess
11-06-2008, 09:41 AM
That's okay. I'm sure if I did some research, I would find it. Unfortunately, this is for someone in another dept that is trying to set this up. And I have 3 other projects that I'm working on now. I keep telling these people, that's what we have an IT dept for! :) LOL

Thanks anyways....

Does anyone else have any suggestions???

Carl A
11-07-2008, 10:18 AM
OBP has a database that should do what you want.
With a little tweaking.
http://vbaexpress.com/forum/showthread.php?t=23189

sburgess
11-07-2008, 10:49 AM
Thanks for the info. I have save the zip file, and when I get the chance, I'll take a look at it.

OBP
11-09-2008, 08:23 AM
Sandy, if you want the latest version, I have it, but if you just want a jpg, (jpeg can cause problems) based Photo database then I have a simpler version of the Document Management database especially for photos.

Dokko
11-10-2008, 09:36 AM
I have a similar problem (i think)

I need to pull through an image file from a table of values, can that be done? (image type is irrelevant)

OBP
11-10-2008, 10:31 AM
If the path to the Image is stored in the table, then yes it is easy to do.
Have you looked at the Database in the link in post #6?

sburgess
11-10-2008, 11:16 AM
A newer version would be great. I think what they are looking for is to be able to pull a picture file, based on criteria. So, I'm assuming that the pics would be housed in a certain folder, and then when a command button was activated, it would look for that file, based on the criteria of a field.

Doesn't sound too difficult, but then anything that doesn't sound difficult, usually is! :hairpull:

Dokko
11-10-2008, 02:59 PM
I've seen a student template downloaded from M$ and they've got a picture presented in a form with the control source and attachment in the student table.

I've tried to do the same but there is no attachment in the data type they have why?

I've also tried to copy and paste the row, but it errors:

'operation is not supported for this type of object'

Could i need to activate an active x control?

OBP
11-11-2008, 06:01 AM
OK, here is a "Photo" based version, rather than all document types.

OBP
11-11-2008, 06:02 AM
Dokko, my version uses VBA to refresh the Photo for each record, perhaps the MS one does as well, if so you will need to copy the code to your version.

Dokko
11-11-2008, 10:10 AM
Dokko, my version uses VBA to refresh the Photo for each record, perhaps the MS one does as well, if so you will need to copy the code to your version.

Sorry to be a total novice but what code would that be? :doh:

OBP
11-12-2008, 08:17 AM
It is the code in the Form's "On Current Event Procedure"

sburgess
11-12-2008, 10:28 AM
Thanks so much for the information - I will check out the file, and see if it's what they are looking for!! :ty: