Hi,
I have some code which alters the final subfolder name in a folderpath. The code works fine.
However, I now want to be able to edit the name of a folder in the middle of the path, i.e. a folder that contains a number of sub-folders. The code I am using errors when I try this. Does anyone know if its possible and what the best VBA function to do it is?
So to be clear - If the rs!SiteName is altered then the code below happily amends the folderpath, however if it is the rs!CompanyName that has changed and needs renaming then the code fails to work.......
I have some code which alters the final subfolder name in a folderpath. The code works fine.
However, I now want to be able to edit the name of a folder in the middle of the path, i.e. a folder that contains a number of sub-folders. The code I am using errors when I try this. Does anyone know if its possible and what the best VBA function to do it is?
So to be clear - If the rs!SiteName is altered then the code below happily amends the folderpath, however if it is the rs!CompanyName that has changed and needs renaming then the code fails to work.......
Code:
Set rs = CurrentDb.OpenRecordset(strSQLJOBS)
rs.MoveLast
rs.MoveFirst
Do Until rs.EOF
rs.Edit
Foldername = rs!folderpath
FoldernameNew = "F:\SFA 20" & Right(rs!OrderDate, 2) & "\Running projects\" & rs!CompanyName & "\J" & rs!OrderID & " " & rs!SiteName & "\"
If Not FolderExists(Foldername) Then
'Foldername doesn't exist so do nothing
rs!folderpath = "Not Set"
Else
'Foldername does exist so rename it and set folderpath for record to new foldername
Name Foldername As FoldernameNew
rs!folderpath = FoldernameNew
End If
rs.Update
rs.MoveNext
Loop
Set rs = Nothing