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 / March 2008

Tip: Looking for answers? Try searching our database.

Creating a Folder/fso vs. MkDir

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LarryP - 05 Mar 2008 16:34 GMT
While searching I read a long but interesting discussion of fso vs. MkDir as
a way to create a folder.  Both appear to work for me, so I lean toward the
simplicity of MkDir, but two questions:

BOTH options appear to create the folder as Read Only, and I can't find
anything in help about how to turn off that feature.  Is there an argument,
or a different command, to change the Read Only attribute?

MkDir is a good alternative to fso.CreateFolder; is there something
comparable for fs.FolderExists?
Douglas J. Steele - 05 Mar 2008 16:47 GMT
I can't think of any reason why either would produce Read Only folders. When
you create a folder (or file) within another folder, it should inherit
permissions from the parent folder. If the user only has Read Only access to
the parent folder, then presumably he/she wouldn't be able to create a
folder at all.

An equivalent of FolderExists is

Function FolderExists(PathToFolder As String) As Boolean
Dim strPath As String

 If Right$(PathToFolder, 1) <> "\" Then
   strPath = PathToFolder & "\"
 Else
   strPath = PathToFolder
 End If

 If Len(Dir(strPath, vbDirectory)) > 0 Then
   FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
 End If

End Function

Signature

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

> While searching I read a long but interesting discussion of fso vs. MkDir
> as
[quoted text clipped - 9 lines]
> MkDir is a good alternative to fso.CreateFolder; is there something
> comparable for fs.FolderExists?
LarryP - 05 Mar 2008 17:12 GMT
Hmmm -- puzzling.  It's right under c:\, so I'm darned if I can see why it
should be read only.  Maybe somebody else will chime in with a way to set it
to Read Only = False....

As to FolderExists, if MkDir doesn't throw an error when the folder already
exists, then that's not going to be a problem.  If it does, I'll use your
code.  Thanks.

> I can't think of any reason why either would produce Read Only folders. When
> you create a folder (or file) within another folder, it should inherit
[quoted text clipped - 32 lines]
> > MkDir is a good alternative to fso.CreateFolder; is there something
> > comparable for fs.FolderExists?
Douglas J. Steele - 05 Mar 2008 18:21 GMT
You'll get an error 75 ("Path/File access error") if the folder already
exists. Of course, an alternative to using that function would be to trap
that error in your error handler, but it's cleaner to check rather than
trap.

Signature

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

> Hmmm -- puzzling.  It's right under c:\, so I'm darned if I can see why it
> should be read only.  Maybe somebody else will chime in with a way to set
[quoted text clipped - 45 lines]
>> > MkDir is a good alternative to fso.CreateFolder; is there something
>> > comparable for fs.FolderExists?
 
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.