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 / Forms Programming / February 2007

Tip: Looking for answers? Try searching our database.

VB code to count the number of folders within a directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pubdude2003 - 08 Feb 2007 19:02 GMT
I would like to write a bit of code into a form that counts the number of
folders in the "D:/1"directory like "* - Done" and like "*". I have found
lots of code that counts files but none that count the folders they reside in.

Can anyone suggest anything?

Thanks!
Brandon Johnson - 09 Feb 2007 16:41 GMT
On Feb 8, 1:02 pm, "pubdude2003 via AccessMonster.com" <u10672@uwe>
wrote:
> I would like to write a bit of code into a form that counts the number of
> folders in the "D:/1"directory like "* - Done" and like "*". I have found
[quoted text clipped - 6 lines]
> --
> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200702/1

   Dim temp As Folders, names As Integer
   Dim oFileSystem As New FileSystemObject
   Set temp = oFileSystem.GetFolder(textbox1)
   names = temp.Count

try that. i havent tested it at all.
Brandon Johnson - 09 Feb 2007 16:42 GMT
On Feb 8, 1:02 pm, "pubdude2003 via AccessMonster.com" <u10672@uwe>
wrote:
> I would like to write a bit of code into a form that counts the number of
> folders in the "D:/1"directory like "* - Done" and like "*". I have found
[quoted text clipped - 6 lines]
> --
> Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200702/1

or even look at this site...
http://abstractvb.com/code.asp?A=716
pubdude2003 - 10 Feb 2007 13:40 GMT
kewl, thanks Brandon, I'm about two code lines from what I want with that web
page link

THANKS!
pubdude2003 - 11 Feb 2007 12:59 GMT
well maybe not two

Private Sub Command1_Click()
FilesInFolder ("D:/1/")
End Sub

 Function FilesInFolder(folderspec) As Long

 Dim objFSO As Object
 Dim objFolder As Object
 Dim filesinfolder2 As Long
 Dim datnumber As Integer
 
 Set objFSO = CreateObject("Scripting.FileSystemObject")
 Set objFolder = objFSO.GetFolder(folderspec)
 Set oFS = CreateObject("Scripting.FileSystemObject")

 Set oF = oFS.GetFolder(folderspec)

 Me!Text10 = oF.subfolders.Count
 
 Set objFolder = Nothing
 Set objFSO = Nothing
End Function
 
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.