B
Blakey300
Hi
I am using Access 2007 and have the following code in a module which i call
using a macro:
Function CreateStudentFolders()
Dim rs As DAO.Recordset
Set rs = Forms!Students.RecordsetClone
If Not rs.BOF And Not rs.EOF Then
Do While Not rs.EOF
CreateFolder rs![LastName] & " " & rs![FirstName] & " " &
rs![MiddleNames] & " " & rs![StudentID]
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 = DLookup("StudentFileLocation", "File Locations")
If Len(Dir(strDesktop & ASubFolder, vbDirectory)) = 0 Then
MkDir strDesktop & ASubFolder
End If
End Sub
This code creates a folder for every student in the database, which works
great except: If i run the code then add another student and try to run the
code again it will not work unless I close and reopen the form.
Is there a way around this?
Regards
Dave
I am using Access 2007 and have the following code in a module which i call
using a macro:
Function CreateStudentFolders()
Dim rs As DAO.Recordset
Set rs = Forms!Students.RecordsetClone
If Not rs.BOF And Not rs.EOF Then
Do While Not rs.EOF
CreateFolder rs![LastName] & " " & rs![FirstName] & " " &
rs![MiddleNames] & " " & rs![StudentID]
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 = DLookup("StudentFileLocation", "File Locations")
If Len(Dir(strDesktop & ASubFolder, vbDirectory)) = 0 Then
MkDir strDesktop & ASubFolder
End If
End Sub
This code creates a folder for every student in the database, which works
great except: If i run the code then add another student and try to run the
code again it will not work unless I close and reopen the form.
Is there a way around this?
Regards
Dave