Run-time error 2220

jibb

Registered User.
Local time
Yesterday, 20:09
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?
 
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
 
Perfect! Thanks.
 

Users who are viewing this thread

Back
Top Bottom