Pictures : store and display

inoxo

Registered User.
Local time
Today, 23:54
Joined
Sep 8, 2005
Messages
42
Lets say an employee form withs the name, the position, the birthdate, ... and a picture of the person.

There are several ways to store pictures in a database, each having pros and cons.

Experienced developpers in dealing with pictures would be kind to tell me the way they recommend to store the picture, and the best way to simply display it on the form.

Thanks,
 
I always Link images.

Pro's:
Stops Db bloating.
Allows a user to edit and update an image easily with their favorite image editor.
Through the windows Common Dialog Box, images are easily added, even for the most basic of PC user.

Cons:
If the Db path changes, or images are deleted, they will no longer be displayed.
If the images are stored on a server and the network is down (never happens, I know) they wont be available.

You can download the zip here http://www.access-programmers.co.uk/forums/showthread.php?s=&threadid=46329 if it helps.


HTH

Dave
 
Last edited:
I agree with OldSoftBoss. Never include an image. Always point to an image. At worst, you would need to load a file spec to the .Image property of a picture control. Which I happen to do in my DB that has my vacation pix in it. I have the file spec as text in my records. In the display form's OnCurrent event, I load the name of the file to the Image property and my picture comes up. On a fast-enough machine, this picture will just spring into existence. At worst, it will "wipe" into existence on slower machines.

This way, you store pix in a convenient place OUTSIDE the DB. Don't forget this incredibly important fact. DBs have limited physical capacity. A couple of really big pix - using the newer 3-8 Mpixel cameras - and your DB gets bloated all to Hell and gone. Your 2Gb DB limit stops you ate only a few hundred included pictures no matter HOW big your hard drive is. But if you only LINK, you can point to tens of thousands of pictures.
 
I used Old Soft Boss's code to create a Land Database that has photos of housing sites... Looks great and very usable.. Prior to this I stored images within the database which was a disaster - database quickly ballooned to 1GB and only had 50 pictures in it. I have about 600 pictures in it now and it's only 21MB.

I would recommend you think carefully about your directory structure and if possible put all your pictures to be referenced in one directory (doesn't really matter what you call it) That way if you want to move the database and include the pictures all you need to do is copy the directory and create it (with the exact same name) at the location where the new db is to reside.
 
I have a DB which allows the user to load a picture. The picture is saved in a folder "images" where the DB is. The DB stores the image path. I use a form to view the images form a list box.

Bones
 
I need a bit of help tracking down a problem. I'm using the link images method recommended aboveand have put the following code in the 'On Load' and the 'On Current' events of my form:

If Not IsNull([txtContactPhoto]) Then
Me!imgContact.Picture = [txtContactPhoto]
End If

However, when I open the form the image does not appear. But if I move to the next record the image for that record appears and if I go back again the image for that record appears as it should. This happens consistently. What am I missing?
 
Take a look at this...

Are you using a Query to move through each record?
Here is a sample code where it will display 2 pictures on a form named FRM. Note the actual image control name is in brackets. This is based on a query

This code takes a link from a record and displays it on a form that has an image controls (imgPic and imgPic1). Note the field names for each record (FrontView and Right View).
Code:
Private Sub Form_Current()

On Error Resume Next
If Not IsNull([FrontView]) Then
    Forms!FRM![imgPic].Picture = [FrontView]
    SysCmd acSysCmdSetStatus, "Image: '" & [FrontView] & "'."
  Else
    Forms!FRM![imgPic].Picture = ""
    SysCmd acSysCmdClearStatus
  End If

On Error Resume Next

If Not IsNull([SideView]) Then
    Forms!FRM![imgPic1].Picture = [SideView]
    SysCmd acSysCmdSetStatus, "Image: '" & [SideView] & "'."
  Else
    Forms!FRM![imgPic1].Picture = ""
    SysCmd acSysCmdClearStatus
  End If

  Exit Sub
End Sub

Hope this Helps.:)
 

Users who are viewing this thread

Back
Top Bottom