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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Folders based on query

Status
Not open for further replies.

sharonniles

Programmer
May 31, 2001
38
US
Hi Everyone,

I want to create create folders based on the results of a query. So for example, let's say the query results are
dogs
cats
birds

I want to create folders
c:\dogs
c:\cats
c:\birds

How do I get the value from the query into the Set fo = fs.CreateFolder("c:\& Me!prPCode") line. Here's what I have so far. Any help will be appreciated.

Private Sub Command1_Click()
Dim DB As DAO.Database, rs As DAO.Recordset
Dim prPCode As Variant
Dim i As Integer
Dim RsSql As String
Dim CurrentValue As Variant
Dim CurrentField As Variant
Dim fs, fo, fo1, fo2, fo3

Set DB = DBEngine.Workspaces(0).Databases(0)

RsSql = "SELECT tblProject.prPCode FROM tblProject WHERE (((tblProject.prDateStart) Between #1/1/2004# And #3/31/2004#));"

Set rs = DB.OpenRecordset(RsSql, dbOpenDynaset)
Set fs = CreateObject("Scripting.FileSystemObject")

Do Until rs.EOF
For i = 0 To rs.Fields.Count - 1
CurrentField = rs(i)



Set fo = fs.CreateFolder("c:\& Me!prPCode")

Next i
rs.MoveNext

Loop




Set fo = Nothing


Set fs = Nothing

End Sub

Thank you,

Sharon Niles
 
Set fo = fs.CreateFolder("c:\& Me!prPCode")
See if this will work instead:
Set fo = fs.CreateFolder("c:\" & Me!prPCode)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thank you TomThumbKP for pointing me in the right direction. Actually the code was

Set fo = fs.CreateFolder("c:\" & CurrentField)

I appreciate your help.

Thanks,
Sharon Niles
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top