Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / May 2004

Tip: Looking for answers? Try searching our database.

Checking if a file exists

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ari - 05 May 2004 03:46 GMT
Hey all

How in VBA would you check to see if a file exists to determine whether to proceed or not

Thanks
ari
Nikos Yannacopoulos - 05 May 2004 11:27 GMT
Ari,

Try something like:

If Dir("PathAndFileName.ext") <> "" Then
   'code to do what you want
Else
   msgbox "File not found"
End If

Dir will return the full apth and file name if the file exists, or an empty
string if it does not.

HTH,
Nikos

> Hey all,
>
> How in VBA would you check to see if a file exists to determine whether to proceed or not?
>
> Thanks,
> ari
dandgard - 05 May 2004 19:14 GMT
Look at the Dir function.  This will allow you to check a directory fo
a file or a set of files that meet a criteria.  If the Dir functio
returns a zero length string if the file does not exist.  There ar
good examples in the Access help files

-----------------------------------------------
~~
~~
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.