Newgrammer
Programmer
Hey guys,
What i'm trying to do is automate creating a large number of file folders by using Access. I already have created all of the "Parent" folders. What I need my code to then do is cycle through each record and create child folder within the parent folders that will be unique. So I will have a parent folder named 1 AA 1234 XX, and within that folder will be 1 AA 1234 01, 1 AA 1234 02 etc.
So each record in my tables have both a unique number, and a parent top level number.
The code I currently have is:
Where I am stuck is that although the code runs fine and without errors, it does not cycle past one record. It creates one folder correctly, and that's it.
I'd love any advice anyone might have as I continue to tinker with it. I'm trying to get this code functional so down the line when i will have 20,000+ parts each with their own folders containing any relevant data.
What i'm trying to do is automate creating a large number of file folders by using Access. I already have created all of the "Parent" folders. What I need my code to then do is cycle through each record and create child folder within the parent folders that will be unique. So I will have a parent folder named 1 AA 1234 XX, and within that folder will be 1 AA 1234 01, 1 AA 1234 02 etc.
So each record in my tables have both a unique number, and a parent top level number.
The code I currently have is:
Code:
Function Folders()
Dim rs As DAO.Recordset
Dim fso, fldr
Dim strSQL, ParentLink, ChildLink As String
Set fso = CreateObject("Scripting.FileSystemObject")
strSQL = "SELECT tblCombinedItemList.strFourthshift, tblCombinedItemList.strFourthshiftTopLevel, tblCombinedItemList.strEcometry, tblCombinedItemList.strEcometryTopLevel, tblCombinedItemList.strDesc, tblCombinedItemList.strDescTopLevel FROM tblCombinedItemList WHERE (((tblCombinedItemList.strEcometry) Is Not Null)) ORDER BY tblCombinedItemList.strEcometry;"
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
ParentLink = ("S:\Home\Wes\Von Morris\Part Database\Files\" & rs!strEcometryTopLevel & " " & rs!strDescTopLevel)
ChildLink = ("\" & rs!strEcometry & " " & rs!strDesc)
rs.MoveFirst
Do Until rs.EOF
If fso.FolderExists(ParentLink & ChildLink) Then
rs.MoveNext
Else
Set fldr = fso.CreateFolder(ParentLink & ChildLink)
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Function
Where I am stuck is that although the code runs fine and without errors, it does not cycle past one record. It creates one folder correctly, and that's it.
I'd love any advice anyone might have as I continue to tinker with it. I'm trying to get this code functional so down the line when i will have 20,000+ parts each with their own folders containing any relevant data.