Access 2010: VBA Code to determine if a file exists.

What is the proper syntax for a procedure that would accomplish this in Access 2010 VBA?

If file exist (FilePath) Then
      Do something
Else
      Do Something else
End If
JAMES125Asked:
Who is Participating?
 
Rey Obrero (Capricorn1)Commented:
If Dir(FilePath) <> "" Then  
    ' File exists
    ' Do something
Else
    ' File does not exists
     ' Do Something else
End If
0
 
Anthony BerenguelCommented:
here's an example that i have used -- it opens the the folder if the folder exists. Modify to tailor it to your situation.
   If Len(dir(this_folder, vbDirectory)) <> 0 Then
            Shell "Explorer.exe /n,/e," & this_folder, vbNormalFocus
        Else
            MsgBox "The directory does not exist!", vbCritical
    End If

Open in new window

0
 
Anthony BerenguelCommented:
sorry, capricorn. Didn't see your solution before I posted mine.
0
 
Rey Obrero (Capricorn1)Commented:
aebea,
np.. it was just seconds away..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.