Update picture in form

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I have a small database of inventory which includes a link to pictures.
The form works well when there is a picture to show, it locates the picture
and displays it on the form.
But when the link to the picture is blank, it shows the picture of the
previous record. It doesn't update itself by removing the picture.

Any way I can fix this??

Thanks
 
Assuming you are loading the images dynamically from a
path, test the path to see if it is valid--if not, show
nothing in the OLE object instead of the image. Here is a
solution that I have used:

In the On Current event for the form, I build the path to
the image--the main path doesn't change, but the image
name does based on its ID stored in the database...

OLEpath$ = "c:\images\" & Me.txtPARTID & ".jpg"
Me.OLEimage.Picture = OLEpath$
Me.OLEimage.HyperlinkAddress = OLEpath$

Here's the rub--you MUST error trap!

On Error GoTo errhnd

In the errhnd, the code is...

If Err.Number = 2220 Then
Me.OLEimage.Picture = ""
Me.OLEimage.HyperlinkAddress = ""
Exit Sub
End If

Error 2220 is an "item/path not valid error"--this is
thrown if there is not a jpg at the path specified with
that name. When it hits the error, it removes the picture
and replaces it with "". Another option would be to
create an image that says "Image Unavailable" and to use
that instead.
 
Back
Top