Results 1 to 7 of 7
  1. #1
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Melbourne, Victoria, Australia
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Pictures in table (Access 2000 SR-1)

    I've created a field (OLE/Object) in a table to contain graphics.
    The db starts of at ~100K, but when I insert one jpeg file with a size of 150k,
    the size of the mdb blows out to ~4.5Mb.
    The reason for inserting rather than linking is that the eventual users
    may not have access to the network folders where the graphic files reside.
    What happens when the graphic is inserted?

    Thanks in advance

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Pictures in table (Access 2000 SR-1)

    It's an unfortunate fact of life with pictures being stored in Access. The bottom line is if you need to store more than about 500 or so pictures, storing them as OLE objects isn't viable. The only answer is to store them in some sort of folder structure, and store the path to the file. The reasons are arcane, but this has been the case since Access 2.0. I've never seen a really down and dirty explanation of why it happens, but I believe it has to do with the fact that they store a full BMP version of the object rather than storing and then converting it each time one is displayed. Others may have further information on this issue.
    Wendell

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pictures in table (Access 2000 SR-1)

    Wendell is correct - regardless of the format of the picture (.jpg, .png, .gif, ...), Access stores the picture PLUS a copy of it in the form of an uncompressed bitmap. Given the compression rate possible with JPEG, it is not surprising that a 150 KB .jpg file corresponds to a .bmp of over 4 MB.

    For example, I just looked up a 1600 by 1200 pixel full color picture taken by a digital camera. As a .jpg with quite passable quality, it is 113 KB; as a bitmap, it is 5,626 KB (1600 x 1200 x 3 bytes = 5,760,000 bytes = 5,625 KB, plus some overhead). Storing the .jpg in the database would cause the .bmp to be stored too, so it would add a total of 5,739 KB plus some overhead to the database!

  4. #4
    New Lounger
    Join Date
    May 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pictures in table (Access 2000 SR-1)

    I would greatly appreciate it if someone could provide specific guidance on how to add images to a form by reference to a file path (so that the image changes as each record changes).

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Pictures in table (Access 2000 SR-1)

    The basic idea is:
    <UL><LI>Put the file path+file name in a text field.
    <LI>Use the On Current event of the form the update the image displayed in an unbound Image control. For example, the following code assumes that the text field is named PicFile and that the image control is named imgPicture:

    Private Sub Form_Current()
    On Error GoTo HandleErr
    If Not IsNull([PicFile]) Then
    [imgPicture].Picture = [PicFile]
    Else
    [imgPicture].Picture = ""
    End If
    Exit Sub

    HandleErr:
    If Err = 2220 Then ' Can't find picture file
    [imgPicture].Picture = ""
    Else
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

    <LI>You can add bells and whistles to let the user browse to a graphics file instead of typing the path+file name.[/list]I have attached a demo Access 97 database; you can convert it to Access 2000 format. The PicFile field is empty now; open the form and click "Insert Picture..." to browse for a graphics file. The database also contains a report that displays the picture(s). Take a look at the code behind the form and the report.
    Attached Files Attached Files

  6. #6
    New Lounger
    Join Date
    May 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pictures in table (Access 2000 SR-1)

    Hans,

    THANK YOU for your very helpful and speedy reply! I will be implementing it over the weekend-with a little luck and a big assist from you.

    Gary

  7. #7
    New Lounger
    Join Date
    May 2001
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Pictures in table (Access 2000 SR-1)

    Hans,

    It worked perfectly. Thanks agian

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •