If its true. Maybe I need to use and insert a unbound textbox for took row numbers from the subfrom.
Am I right ?
Sorry, there is some disconnect between what you are asking for and what I think you are asking for.
Are you talking about records or folders? Look at the code I posted to see how it creates two folders. It does NOT use a loop so it only creates one two tier path at a time. If you need to process multiple files, each of which could cause a new folder to be created, you need to put the code I suggested into a loop.
EACH level of folder must be created ONE at a time. I have no idea what your folder scheme is so I don't know whether or not each would require separate action. in my case, the high levels are created when the application is created. All the files are downloaded to a single folder from our third party vendor that opens the letters and scans the documents. The name the documents with the CompanyID, the EmployeeID, the scan date, and the docType. If there are multiple documents of the same type for the same employee received on the same day, there is also a suffix. All the parts of the name are separated with underscores to make parsing simple. So a file might be named:
ACME_1234_20230102_MarriageLicense.PDF
The process reads the download folder and for each file parses the name. It starts by looking for "ACME". If the folder doesn't exist, it creates it. Then it looks at "1234" and sees if Customer "ACME" has an employee with ID = "1234", If so, it logs the file name and copies the file from the download folder to the "ACME" folder. If an error occurs at any point, the code looks to see if the "Error" folder exists, if it doesn't, it is created in the download folder and the file is moved there. After all files have been processed. The inner counts are compared to the count of documents in the download folder. If there is no error, the documents in the download folder are deleted.
This particular process doesn't need to create multiple levels of folders but it does create two types. I creates a folder that is hardcoded with the name "Error" under the download folder and it creates multiple folders at the same level, one at a time whenever it encounters a new Company. I have others that do. But the logic is the same, just one level at a time, In all cases, the first time ever that the code runs, lots of folders will be created. Eventually, new folders only need to be created occasionally as a new company or employee is added to the application.
In the process I described above, it might be rational to create a child folder for each employee. My client didn't want to do that but maybe that is what you want. So, the code would continue processing the file name. After validating that the employeeID is valid, the code could then check to see if the folder for that employee existed yet and if not, create it and then move the file to that folder. So, in this case, if the top level path was:
D:\AccessApps\InsuranceAudit\ Then, the code would produce two lower level folders if necessary:
D:\AccessApps\InsuranceAudit\ACME\1234
It might also need to create the Errors folder:
D:\AccessApps\InsuranceAudit\Errors