I have a command button open an image in an unbound ole box,
ie. Me![imageframe].Picture = Me![imagepath], how can I check that the file Me![imagepath] is present so that I don't get an error,
if Dir(Me![imagepath]) <> "" then
Me![imageframe].Picture = Me![imagepath]
else
msgbox "Image File does not exist"
End If
Note that this technique does not protect against referencing a drive which does'nt exist; otherwise its OK. You'd want to add some error handling to trap this, or check the prefix of the imagepath to see if a drive is referenced. Perhaps a better method exists to test for the drive.
Anyway, hope this does the trick,
Cheers,
Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
Hi,
Just use the Dir command (works in a similar way to the DOS DIR command) e.g
Sub PicCommandButton_Click()
If Dir(Me![imagepath]) <> "" Then
Me![imageframe].Picture = Me![imagepath]
Else: Me![imageframe].Picture = "c:\default picture.jpg"
End If
' If file exists then show picture else show a default picture
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.