Run-time error 2220 (1 Viewer)

jibb

Registered User.
Local time
Today, 01:40
Joined
Dec 1, 2011
Messages
93
I've got the following code in a form to display an image:

Code:
Me.imgIMAGE.Picture = "[URL="file://\\C:\images"]\\C:\images[/URL]\jpgs\" & Me.cboPRODUCT_CODE.Column(0) & ".jpg"

If there isn't an image with that name how do I stop it showing the error?
 

PeterF

Registered User.
Local time
Today, 10:40
Joined
Jun 6, 2006
Messages
295
You stop the error by testing if the file exists like:
Code:
   Dim PictureFile as string
   Picturefile = "\\C:\images\jpgs\" & Me.cboPRODUCT_CODE.Column(0) & ".jpg"
   if len(dir(picturefile)) > 1 then
      Me.imgIMAGE.Picture = picturefile
   Else
      Me.imgIMAGE.Picture = ""
   End if
 

jibb

Registered User.
Local time
Today, 01:40
Joined
Dec 1, 2011
Messages
93
Perfect! Thanks.
 

Users who are viewing this thread

Top Bottom