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 / Modules / DAO / VBA / November 2004

Tip: Looking for answers? Try searching our database.

Validate existance of a directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 18 Nov 2004 03:24 GMT
Hello,

   I want to set a startdir variable = "//public/common/%username%" if the
computer has access to the folder otherwise set it equal to "c:\".  How can
this be done?

Thank you,

Daniel
Allen Browne - 18 Nov 2004 04:07 GMT
Dir() can search for folders. The function below provides an example
wrapper.

You will need to pass in a string. To get the username, you might be able to
use:
   Environ("username")
or you may prefer to use an API call:
   http://www.mvps.org/access/api/api0008.htm

Public Function FolderExists(varPath As Variant) As Boolean
   On Error Resume Next
   If Len(varPath) > 0& Then
       FolderExists = (Len(Dir$(varPath, vbDirectory)) > 0&)
   End If
End Function

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Hello,
>
[quoted text clipped - 6 lines]
>
> Daniel
Daniel - 18 Nov 2004 12:59 GMT
I've tried to use an if statement to verify if the directory exist because
the help file explained that the dir function returned "" if the folder did
not exist

if dir("c:\temp")="" then
   msgbox "this directory does not exist"
end if

but I can't seem to get it to work.Could you point out my mistake.

Thankyou

Daniel

> Dir() can search for folders. The function below provides an example
> wrapper.
[quoted text clipped - 22 lines]
> >
> > Daniel
Douglas J. Steele - 18 Nov 2004 13:28 GMT
You're missing the second parameter, vbDirectory:

if dir("c:\temp", vbDirectory)="" then
    msgbox "this directory does not exist"
end if

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> I've tried to use an if statement to verify if the directory exist because
> the help file explained that the dir function returned "" if the folder did
[quoted text clipped - 38 lines]
> > >
> > > Daniel
 
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.