Pictures in Database

C

canyon

I want to add pictures to each record in my database. I
have JPEG files and would like to add the path and
filename to the fields, but also be able to view the
pictures easily from the form view. OLE bound objects
seem to be cumbersome and bog the database down. What
options should I consider to do this effectively? I'm
open to any suggestions.
 
J

Joe Fallon

If you are interested in storing the picture in the database check out
Stephen Lebans' web site:
http://www.lebans.com/loadsavejpeg.htm

The approved solution is to store the path and display the picture
dynamically.
How to Link a Picture to a Form:

Use an unbound image frame named: ImageFrame
and add a field to your table called ImagePath.

To add the picture to a report just use code like this in the On Format
event of the Detail Section.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me![ImageFrame].Picture = Me![ImagePath]
End Sub

In the OnCurrent event of the form use this code:

Private Sub Form_Current()
On Error GoTo Err_Form_Current

If IsNull(Me![ImagePath]) Then
Me![ImageFrame].Picture = "c:\msaccess.jpg"
Else
Me![ImageFrame].Picture = Me![ImagePath]
End If

Exit_Form_Current:
Exit Sub

Err_Form_Current:
Select Case Err.Number
Case 2220
'ignore the Can't Load Image error
Case Else
MsgBox ("Error # " & Str(Err.Number) & " was generated by " &
Err.Source & Chr(13) & Err.Description)
Resume Exit_Form_Current
End Select

End Sub

The image takes a second or two to load. A dialog is put on screen too.
This process can get very annoying after a while because it happens every
time the user navigates to another record.

From Tony Toews' web site: http://www.granite.ab.ca/access/imagehandling.htm
Getting tired of seeing that Loading Image dialogue flicker? Getting errors
by users who click on things before this is finished displaying? Try
creating/changing the following registry key
HKEY_LOCAL_MACHINE\Software\Microsoft\Shared
Tools\GraphicsFilters\Import\JPEG\Options
ShowProgressDialog to No

I use the Tab control to "hide" the image on a different "page".
I also move the code to the OnGotFocus event of the ImagePath text box
which is on the next page of the Tab control.
This way, the only time the picture loads is when the user clicks the tab to
see it.
 
E

Exponent

Handle the Form_Current event (forms) or the Detail_Format event (reports) to load the file into an image
control.

Ideally, only store the filename and generate the full path at runtime (e.g. relative to the database file).

Note that the image control requires that the necessary Office Graphics filters are installed on the system,
and that these are not redistributable. If your application runs on several systems this can be a configuration
and maintenance headache. Check out Stephen Lebans’ site for workarounds to this: http://www.lebans.com/

Additional workarounds for the image control are available at ‘The Access Web’ at: http://www.mvps.org/access/toc.htm
(scroll too quick crash, suppress loading dialog etc). A ‘browse for file’ sample is also available there.

For enhanced capabilities (zoom, scroll, rotate, resample/thumbnail, EXIF, TWAIN etc) consider using a
third party image control designed for Access, such as our own – for info see the link below.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top