Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filename Does Not Exist ! 2

Status
Not open for further replies.

leckie

Programmer
Apr 19, 2001
65
GB

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,

thankyou in anticipation . .
 
Here's one way:

if Dir(Me![imagepath]) <> &quot;&quot; then
Me![imageframe].Picture = Me![imagepath]
else
msgbox &quot;Image File does not exist&quot;
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]) <> &quot;&quot; Then
Me![imageframe].Picture = Me![imagepath]
Else: Me![imageframe].Picture = &quot;c:\default picture.jpg&quot;
End If
' If file exists then show picture else show a default picture
End Sub

Good luck

Alex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top