Search for File before showing link?

G

G

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
 
R

Ron Weiner

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top