I have used the code below in a button to create a folder on the hard drive when I add a new customer is it possible to create subfolders within that folder at the same time
Private Sub Command96_Click() Dim FSO As New FileSystemObject Dim FolderName As String FolderName = Myfolder & (Forms!customerf.FirstName) & " " & (Forms!customerf.LastName) If Not FSO.FolderExists(FolderName) Then FSO.CreateFolder (FolderName) End If Set FSO = Nothing End Sub
Regards
Carl
Adam Schwanz
@Reply 4 years ago
Sure, should work to just run the code again after with a modified form name in the same button.
Dim FSO As New FileSystemObject
Dim FolderName As String
FolderName = Myfolder & (Forms!customerf.FirstName) & " " & (Forms!customerf.LastName)
If Not FSO.FolderExists(FolderName) Then
FSO.CreateFolder (FolderName)
End If
Set FSO = Nothing
Dim FSO2 As New FileSystemObject
Dim FolderName2 As String
FolderName2 = Myfolder & (Forms!customerf.FirstName) & " " & (Forms!customerf.LastName) & "\NewFolder"
If Not FSO2.FolderExists(FolderName2) Then
FSO2.CreateFolder (FolderName2)
End If
Set FSO2 = Nothing
Carl BushOP
@Reply 4 years ago
Hi Adam thanks very much for your help that worked a treat I wanted a customer folder with 4 subfolders so just copied your code another 3 times it's probably not as elegant a solution as you or the great man would use but it works and I'm over the moon
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Access Developer 33.