I am trying to use mkdir to create a folder structure for each property that comes into a real estate inventory.
I can create a root level folder with the respective property address using:
MkDir "P:\\properties\" & Me.Address
I would ideally like to create the following structure after the aforementioned folder is created with the address name:
p:\properties\address\bids
p:\properties\address\before pictures
p:\properties\address\after pictures
p:\properties\address\subcontractors
I have tried:
MkDir "P:\prism\properties\" & Me.Address1\"Bids" and variants of that without success. Can this be done with MKDIR?
Thank you for any assistance.
-Scott
Using MKDIR to create a set of folders
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
-
- Administrator
- Posts: 12629
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Using MKDIR to create a set of folders
Mkdir "P:\prism\properties\" & Me.Address & "\Bids"
etc.
etc.
StuartR
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
Re: Using MKDIR to create a set of folders
Stuart,
Thank you for your help. Here is what I have: (the specific field referenced is address1)
Private Sub cmbtMakeFolders_Click()
MkDir "P:\prism\properties\"& Me.Address1"\Bids"
MkDir "P:\prism\properties\"& Me.Address1"\BeforePictures"
MkDir "P:\prism\properties\"& Me.Address1"\AfterPictures"
MkDir "P:\prism\properties\"& Me.Address1"\Subcontractors"
End Sub
and I get a "Compile Error, Syntax Error"
Did this follow your instructions properly?
Thank you for your time.
-Scott
Thank you for your help. Here is what I have: (the specific field referenced is address1)
Private Sub cmbtMakeFolders_Click()
MkDir "P:\prism\properties\"& Me.Address1"\Bids"
MkDir "P:\prism\properties\"& Me.Address1"\BeforePictures"
MkDir "P:\prism\properties\"& Me.Address1"\AfterPictures"
MkDir "P:\prism\properties\"& Me.Address1"\Subcontractors"
End Sub
and I get a "Compile Error, Syntax Error"
Did this follow your instructions properly?
Thank you for your time.
-Scott
-
- Administrator
- Posts: 78632
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Using MKDIR to create a set of folders
Please read Stuart's reply more carefully, there should be an extra & (surrounded by spaces) after Me.Address1.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
Re: Using MKDIR to create a set of folders
Thank you Hans. My eyes are very bad and I flat out didn't notice that.
I have added the spaces in keeping with Stuart's suggestion and I am still getting the same error:
Private Sub cmbtMakeFolders_Click()
MkDir "P:\prism\properties\" & Me.Address1 & "\Bids"
MkDir "P:\prism\properties\" & Me.Address1 & "\BeforePictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\AfterPictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\Subcontractors"
End Sub
Can you see if I am missing anything else?
Thank you. - Scott
I have added the spaces in keeping with Stuart's suggestion and I am still getting the same error:
Private Sub cmbtMakeFolders_Click()
MkDir "P:\prism\properties\" & Me.Address1 & "\Bids"
MkDir "P:\prism\properties\" & Me.Address1 & "\BeforePictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\AfterPictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\Subcontractors"
End Sub
Can you see if I am missing anything else?
Thank you. - Scott
-
- Administrator
- Posts: 78632
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Using MKDIR to create a set of folders
This code shouldn't cause a compile error - it is syntactically correct. It might cause a runtime error if you haven't created the folder
"P:\prism\properties\" & Me.Address1
yet. Are you sure you have done that?
"P:\prism\properties\" & Me.Address1
yet. Are you sure you have done that?
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
Re: Using MKDIR to create a set of folders
I have built the base path:
P:\PRISM\Properties
Now I get a "run time error 76 - path not found"
Path is created and the code looks appropriate:
Private Sub cmbtMakeFolders_Click()
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\Bids"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\BeforePictures"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\AfterPictures"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\Subcontractors"
Not sure what I am missing.
P:\PRISM\Properties
Now I get a "run time error 76 - path not found"
Path is created and the code looks appropriate:
Private Sub cmbtMakeFolders_Click()
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\Bids"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\BeforePictures"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\AfterPictures"
MkDir "P:\PRISM\Properties\" & Me.Address1 & "\Subcontractors"
Not sure what I am missing.
-
- Administrator
- Posts: 78632
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Using MKDIR to create a set of folders
You can't create two levels of subfolders in one step, so you need to add one more line, to create the subfolder "P:\prism\properties\" & Me.Address1, before creating subfolders of that folder:
Code: Select all
Private Sub cmbtMakeFolders_Click()
MkDir "P:\prism\properties\" & Me.Address1
MkDir "P:\prism\properties\" & Me.Address1 & "\Bids"
MkDir "P:\prism\properties\" & Me.Address1 & "\BeforePictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\AfterPictures"
MkDir "P:\prism\properties\" & Me.Address1 & "\Subcontractors"
End Sub
Best wishes,
Hans
Hans