creating new folders

B

Blakey300

Hi

i have the following code, which creates a folder for each record:-

Option Compare Database
Option Explicit

Function CreateGradingFolder()

Dim rs As DAO.Recordset

Set rs = Forms![Grading Events (Edit)].RecordsetClone
If Not rs.BOF And Not rs.EOF Then
Do While Not rs.EOF
CreateFolder rs![EventID] & " " & rs!Format([EventStartDate], "yyyy
mm dd")
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing



End Function

Private Sub CreateFolder(ASubFolder As String)

Dim strDesktop As String
Dim strSubfolder As String

strDesktop = "C:\Keibudo Karate Schools\Documents\Event Documents\Grading\"

If Len(Dir(strDesktop & ASubFolder, vbDirectory)) = 0 Then
MkDir strDesktop & ASubFolder
End If

End Sub

I know the is an error in the following line:

CreateFolder rs![EventID] & " " & rs!Format([EventStartDate], "yyyy mm dd")

I think it should be obvious what i am trying to acheive but i am not very
good at code so i was wondering if someone can recommend how to sort this.

Regards

Dave
 
D

Douglas J. Steele

I don't believe that will work, due to the spaces in the folder name. I
believe you need quotes around it:

CreateFolder """" & rs![EventID] & " " & Format(rs![EventStartDate], "yyyy
mm dd") & """"

or

CreateFolder Chr$(34) & rs![EventID] & " " & Format(rs![EventStartDate],
"yyyy mm dd") & Chr$(34)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Daniel Pineault said:
Your recordet is not Format but rather EventStartDate. Try:

CreateFolder rs![EventID] & " " & Format(rs![EventStartDate], "yyyy mm
dd")

--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



Blakey300 said:
Hi

i have the following code, which creates a folder for each record:-

Option Compare Database
Option Explicit

Function CreateGradingFolder()

Dim rs As DAO.Recordset

Set rs = Forms![Grading Events (Edit)].RecordsetClone
If Not rs.BOF And Not rs.EOF Then
Do While Not rs.EOF
CreateFolder rs![EventID] & " " & rs!Format([EventStartDate],
"yyyy
mm dd")
rs.MoveNext
Loop
End If
rs.Close
Set rs = Nothing



End Function

Private Sub CreateFolder(ASubFolder As String)

Dim strDesktop As String
Dim strSubfolder As String

strDesktop = "C:\Keibudo Karate Schools\Documents\Event
Documents\Grading\"

If Len(Dir(strDesktop & ASubFolder, vbDirectory)) = 0 Then
MkDir strDesktop & ASubFolder
End If

End Sub

I know the is an error in the following line:

CreateFolder rs![EventID] & " " & rs!Format([EventStartDate], "yyyy mm
dd")

I think it should be obvious what i am trying to acheive but i am not
very
good at code so i was wondering if someone can recommend how to sort
this.

Regards

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top