Re: Storing and displaying pictures with MS Access -D7



If I might make a suggestion (I've done a lot of work in MS Access), don't
store the images in Access tables if you can avoid it. At least up through
version 2k, OLE fields seem to be sort of unstable depending on your setup
(network and such).

I have 2 big Access apps out there that make extensive use of images.

One of them stores thousands of images of CD cover art (for a music
catalog). The original programmer stored the images in the tables. They had
speed issues and corruption issues and the mdb was unecessarily huge. So we
changed it to store the images as jpg or bmp files in a folder on the server
and reference them by some naming strategy. For the music catalog we saveed
the image files with a file name that matched the catalog number of the CD.

The other program stores the image files with a file number that matches the
part number of the item in question. When that part or CD is called up on
a form or a report, we simply look for the associated image on disk and show
it. (of course you can add code to allow users to use a different image or
even call up some image editing too also).

As a matter of fact I also just wrapped up an MS Access/ SQL 2000 program
where we store pdf files on disk and create list boxes of the files for each
client record. The user can double click an item in the list and Acrobat
reader opens up so they can veiw the file. In that system we have a series
of folders for each client where the folder name simply matches the primary
key of the client record.

All of these work very smoothly. One thing I need to mention however is that
if you use jpg files, there is a small delay sometimes (depends on your
system resources) when opening up a form or report due to the system having
to decompress the file to display it. If a user clicks through records too
fast, sometimes an error occurs if the file has not had time to decompress.
We just worked around the error.. Of course bmp files do not produce such a
delay but then they take up a lot of disk space.

Of course if catalog or part numbers are able to change then you need code
to change the associated file names as well. We did that for the pdf work.
Not a big deal.

Here's my Access function that retrieves the image file for use on a form or
report:

Public Function fncSetImageFile(varFileName As Variant, strFileExt As
String)
On Error GoTo Err_fncSetImageFile

Dim bolFileFound As Boolean
bolFileFound = False

'set the image file to the default of none available.
fncSetImageFile = "ImageNotAvailable"

If IsNull(varFileName) Or varFileName = "" Then
'if there is no image file name passed, use the setting from above.
Else
If Dir(strImageFilePath & varFileName & strFileExt) = "" Then
'If there is a file name passed, but it does not exist on disk,
leave it as it was set above (no image file)
Else
bolFileFound = True
'the file name is passed and it is indeed found on disk.
End If

If bolFileFound Then
fncSetImageFile = strImageFilePath & varFileName & strFileExt
End If
End If

Exit_fncSetImageFile:
Exit Function

Err_fncSetImageFile:
If Err.Number = 3021 Then
GoTo Exit_fncSetImageFile
End If
MsgBox Err.Description & ": " & Str(Err.Number)

End Function

And here's the calling routine in one of the form on current event:

'get the image files
If fncSetImageFile(Me!PartNumber, ".bmp") = "ImageNotAvailable" Then
Me!lblPartImageNotAvailable.Visible = True
Me!PartImage.Visible = False
Else
Me!lblPartImageNotAvailable.Visible = False
Me!PartImage.Visible = True
Me!PartImage.Picture = fncSetImageFile(Me!PartNumber, ".bmp")
End If

PartImage is just an Image object.

HTH,

Keith

"Jacques" <jacques.noah@xxxxxxxxxxxxxx> wrote in message
news:42739bc1@xxxxxxxxxxxxxxxxxxxxxxxxx
Does anyone one know how to store and retrieve pictures(jpg,bmp etc) in a
Access database? I tried to follow a tutorial on it at
http://delphi.about.com but that example does not seem to work.

Can anyone help?
Thanks



.



Relevant Pages

  • Re: Outlook locks up with a officelifeboathang
    ... The store C:\Documents and Settings\rhs\Local Settings\Application ... Data\Microsoft\Outlook\PersFold References.pst has detected a catalog ... checkpoint. ... ID: 6, Application Name: Microsoft Office Outlook, Application Version: ...
    (microsoft.public.outlook.general)
  • Re: RadioShack shares hit low on downgrade, analyst cites Cingular as cause for the downgrade.
    ... Anyone who grew up with Radio Shack would not recognize the store in its ... I was a RS store manager from '71-'74, when Citizens Band Radios were all ... Without that catalog in the hands of their customers, ...
    (alt.cellular.cingular)
  • Re: How to open a laptop battery?
    ... and built, or even just built, their own rigs. ... We visited the store in Denver once, after we bought the multi-kit breadboard that made something like 20 different electronic items ranging from a code key with a light bulb up to an AM transmitter. ... The Jerryco catalog, years later, was almost as much fun, and when a store opened in Virginia Beach that was the living embodiment of Jerryco, it was like the return of those fabulous catalogs of my youth, only now I could afford to buy some of the stuff. ...
    (rec.arts.sf.fandom)
  • Re: A new Penzeys
    ... But I've never been to a Penzeys store... ... stores in their early years, no web site, and their catalog consisted ... probably toss all those curry blends ...
    (rec.food.cooking)
  • Re: WMP stuck in endless install loop...
    ... That particular error should mean that the your system catalog store at some ... believe that the WMP10 installer would be able to bypass the system problems ... See http://zachd.com/pss/pss.html for some helpful WMP info. ...
    (microsoft.public.windowsmedia.player)