Hi all,
I have several databases that make use of the mkdir function to verify that year and month folders are always created before storing reports. To save room and make my code more efficient, I wrote a function, CheckForPaths, that accepts two string arguments, and uses if functions to call mkdir (where needed). Sometimes I need to make more than two paths ... sometimes three, or even four or six. To handle extra paths, I created CheckOnePath.
I will call the functions several times, as needed, to create the correct number of paths.
How can I rewrite my functions so that I only have one? That is, could I rewrite CheckForPaths so that I can call:
call CheckForPaths(onePath)
call CheckForPaths(onePath, twoPath)
call CheckForPaths(onePath, twoPath, ..., nPath)
?
Thanks!
I have several databases that make use of the mkdir function to verify that year and month folders are always created before storing reports. To save room and make my code more efficient, I wrote a function, CheckForPaths, that accepts two string arguments, and uses if functions to call mkdir (where needed). Sometimes I need to make more than two paths ... sometimes three, or even four or six. To handle extra paths, I created CheckOnePath.
I will call the functions several times, as needed, to create the correct number of paths.
How can I rewrite my functions so that I only have one? That is, could I rewrite CheckForPaths so that I can call:
call CheckForPaths(onePath)
call CheckForPaths(onePath, twoPath)
call CheckForPaths(onePath, twoPath, ..., nPath)
?
Thanks!
Code:
Option Compare Database
Public Sub CheckForPaths(sPath1 As String, sPath2 As String)
If Len(Dir(sPath1, vbDirectory)) = 0 Then
MkDir (sPath1)
End If
If Len(Dir(sPath2, vbDirectory)) = 0 Then
MkDir (sPath2)
End If
End Sub
Public Sub CheckOnePath(sPath3 As String)
If Len(Dir(sPath3, vbDirectory)) = 0 Then
MkDir (sPath3)
End If
End Sub