Importing Photos

fredfox

Foxy
Local time
Today, 04:56
Joined
Jun 10, 2005
Messages
14
Have can I apply individual photo's to members records.
One photo for the one person in each record.

Foxy
 
More or less. Search this forum, or Mr. Clipit (Access Help) for articles concerning OLE objects.

With these, you can LINK a variety of files to a record on the database. You cannot import them. You'll still be able to view them on a form, as OLE objects are just like any other field in a table. They will be separate files, however.

Andrew
 
Easy way to load employee pictures

I wouldn't even go so far as OLE insertion. OLE for pictures works but you don't need it if you did a proper install of Access to include "wizards" and "translators" for all common picture types. If you did, the solution is really simple.

On your server, create a directory (folder) where you keep photo files. In your personnel record, include the name of the photo file for the employee. Make every photo name unique. Perhaps the person's name all smushed together. Perhaps the person's employee number. Perhaps just a sequence number. Doesn't matter. Just has to be unique within the folder. Make the folder's permissions read-only to the average user, "MODIFY"-class permissions to whomever has the right to add or delete or replace photos.

ADDED NOTE: if the photos are in the same folder as the .MDB itself, all users need MODIFY-class permissions because of .MDB and .LDB issues - which is why I would suggest a separate folder that is read-only to some users. On the other hand, if your network or file server guru doesn't want to set it up this way, perhaps you don't care. I would still have a separate sub-folder only because you don't want to clutter up the .MDB file's folder.

On your personnel form, build an unbound image control. When you execute a form_current event on that form, find the name of the photo file from the recordset that underlies the form. The file name could be either visible or not. (If "NOT" - make it go into a text box for which the .VISIBLE property is NO.) The VBA code just has to be able to see the name. Nobody else does.

OK, you've got the photo file name, you know the folder name. Concatenate the name with other information as required for building a fully qualified file specification. Store this result in the .Picture property of the image control. If you have the proper image handlers loaded, it will come up pretty fast. On a box with 1.5 GHz or more, you might just see the image appear without ever seeing the unbound image control as an empty control. Even on a really old clunker 400 MHz box, most of the time I never see more than a really brief flicker. On my 2.8 GHz box, it is just there the moment I change to a new user record.

You might want to experiment with some of the other properties. The one you DON'T want is the option to EMBED the picture. NEVER EVER USE THIS OPTION. It leads to rapid DB bloat and kills system performance. Use the LINK option. Now, how you treat the other things like ZOOM and aspect ratio controls - that's your call.
 
Last edited:
Embed pictures

Many thanks for your help but I am still confused how to do it.
It should be simple but I have tried to follow your info to no avail.

Would you be so kind as to put it in basic laymans terms as I am new to all of this and my ability is in desperate need of improvement.

fredfox
 
Read up on EVENT routines, the ONCURRENT event, and IMAGE CONTROLS. Read up on VBA and String data types. Links in the Access Help files will lead you to properties of the various controls. One of the properties of an image control is the PICTURE - which is actually the name of a file that contains the picture. Other properties deal with whether the picture automagically zooms to fit the image window, whether it "tiles" instead, and whether it maintains the aspect ratio of the original image format. One of the properties is whether you LINK or EMBED. I've already made my position clear on that one. NEVER EMBED if you can LINK instead.

Create the form on which you want to show this picture. I'm assuming it will also show person's name, employee number, department, supervisor, approximate number of teeth showing when they grin, etc. All of this will come from the table that drives the form. (a.k.a. "underlying table") On this form, build an IMAGE control that does not have a pre-defined field as its controlsource. (That is a property of controls.) Leave the controlsource blank. This makes the image UNBOUND. I.e. nothing in it.

OK, in the underlying employee table, include a text field for the name of the photo file. If they are all .JPG (JPEG) files and all of them are in the same exact path, say, something like S:\Shared\Employees\Photos, then you don't need to store either of these. Store the file names for every photo. Naming conventions are more or less up to you. If you wanted to use employee number as a file name (after converting it to text), that works. If you want to take the first 3 letters of the first and last names plus the middle initial and a digit in case two folks have very similar names, that would work. But that is far from the ONLY way to do this. Like I said earlier, your call as to naming.

OK, in design mode, look at the properties of the form. Call up its properties. The list includes events. Double-click the box for OnCurrent. You will get a subroutine header and trailer built automagically for the event routine. Now just fill it in.

In the "Form_OnCurrent" event routine, the form has just been loaded with new data. The event "fires" every time you navigate to a new or different old record. The underlying record from the table is available for this employee at the time the event fires. It is a text field, probably.

So in that routine, you have to pick up the file name. You already know the path and you already know you are storing only .JPG files. (For the sake of argument, agree with me for a moment.) So using the constant string that is the path to your photo folder and the constant string that is your file time, concatenate (see "&" operator) the path, name, and type. Store that in the .PICTURE property of the image control.

Now... what if you have .JPG and .PCX as possible picture formats? Then you have to store the picture file's name and type instead of just storing the name. But IF you do this, ALL entries must include a file type in the underlying table. You would still have to concatenate the file name and type with the path.

What if you use different folders based on some arbitrary criteria - such as department or division or physical work area? (It could happen...). Then you have to store the folders for each entry, but don't have to do any concatenation at all.

Browse the Help files as I suggested and read over this slightly more detailed explanation. Then heck, just try it. As long as you don't DELETE anything, you won't hurt yourself too much.

Just to be safe, make a good backup copy first.
 

Users who are viewing this thread

Back
Top Bottom