Update picture in form

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
 
W

woloman

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.
 

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