Search for File before showing link?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've set up a label on a form and the ON CLICK Event Procedure opens a file.
Here's the code:

ImagePath = "c:\" & Trim(Me.salesnumber) & ".jpg"
Shell """C:\Program Files\Internet Explorer\iexplore.exe"" " & ImagePath

The problem is that there may not be a file stored at this location so an
error appears (not very elegant). Before displaying the link, I would like
to first scan the folder location for this file.

If the file is in the folder, show the link, else, hide the link.

Any suggestions are welcome. Thank you in advance for your time.

Gary
 
Gary

You could try something like:

If Len(Dir("c:\" & Trim(Me.salesnumber) & ".jpg")) > 0 then
' File exists
Else
' File does not exist
End IF

Ron W
 
That did it, thanks, Ron!

Ron Weiner said:
Gary

You could try something like:

If Len(Dir("c:\" & Trim(Me.salesnumber) & ".jpg")) > 0 then
' File exists
Else
' File does not exist
End IF

Ron W
 
Back
Top