Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2012-09-20
4
Medium Priority
?
6,035 Views
Last Modified: 2012-09-20
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
0
Comment
Question by:JAMES125
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 38418750
If Dir(FilePath) <> "" Then  
    ' File exists
    ' Do something
Else
    ' File does not exists
     ' Do Something else
End If
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38418751
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
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 38418753
sorry, capricorn. Didn't see your solution before I posted mine.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38418759
aebea,
np.. it was just seconds away..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question