Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to create a set of folders for multiple records

Status
Not open for further replies.

SWiebe

Technical User
Jan 18, 2006
2
CA
I need to create a set of folders (1 folder with 3 subfolders) for each record in a database. The database has first name, last name and ID Number fields and I want the root folder to be called by the last name, first name and IDNUM and the subfolders will have standard names for all. Can anyone help me come up with code to automate this. I have to create this set of folders for about 2500 individuals. Thanks
 
This should create the top level
Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTemp As String

Set db = CurrentDb
Set rs = Db.OpenRecordset ("Yourtable")

Do While Not rs.Eof
  strTemp = rs!Surname & " " & rs!Forename & " " & rs!IDNumber
  If Dir (strTemp, vbDirectory) <> "" Then 
    MkDir strTemp
  Else
    Debug.Print "Folder " & strTemp & " exists"
  End If
  rs.MoveNext
Loop

rs.Close
Set Db = Nothing

To create the sub folders, you need to issue another Mkdir command as strTemp\<sub folder name> before moving to the next record.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top