How loop through records and create folders for each record on a server drive

I have a database that contains several records related to properties.  I want to somehow run a function that will create a folder on a server drive for me for each of this properties just by clicking a button on a temporary form.

The schema for the folders on the server will be like:

Master Folder Name (to be named "Properties"
>>>>>City, State (from the property record)
>>>>>>>>>>Property Name (from the Property record)

In other words as an example like this screen shot:

Server folder example
How can this be done?
SteveL13Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
what is the name of the table? and the fields on the table?

upload a sample db with the table.
0
SteveL13Author Commented:
Database sample attached.
Make-Folders.accdb
0
Rey Obrero (Capricorn1)Commented:
what is the path to the server?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Rey Obrero (Capricorn1)Commented:
First copy this line to the top of a regular module

Option Compare Database
Option Explicit

Public Declare Function MakeSureDirectoryPathExists Lib "imagehlp.dll" (ByVal lpPath As String) As Long

Open in new window



then use this codes in the click event of the button

Private Sub cmdCreateFoldersonServer_Click()
Dim rs As DAO.Recordset, strFolder As String
Set rs = CurrentDb.OpenRecordset("tblProperties")
Do Until rs.EOF
strFolder = "\\ServerName\SharedFolderName\Properties\" & rs!City & "\" & rs!State & "\" & rs!PropertyName & "\"

MakeSureDirectoryPathExists strFolder

rs.MoveNext
Loop
rs.Close
End Sub

Open in new window


change  \\ServerName\SharedFolderName  accordingly



.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteveL13Author Commented:
Absolutely perfect!!!  I did change one line to add the property ID and put the city and state in the folder name...

strFolder = "C:\Properties\" & rs!City & " " & rs!State & "\" & rs!ID & " - " & rs!PropertyName & "\"
0
SteveL13Author Commented:
Absolutely amazing.  Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.