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!

Issues with MkDir command 1

Status
Not open for further replies.

Sech

Programmer
Jul 5, 2002
137
GB
I have a database which needs to create new directories on the fly as follows...

sCurrentDir = Dir("T:\Customer Support\VFSalesMI\Orders & Deliveries\" & CStr(lYear) & "\" & sMonthNo & sYearNo & "\", vbDirectory)
If sCurrentDir = "" Then
sNewDir = "T:\Customer Support\VFSalesMI\Orders & Deliveries\" & CStr(lYear) & "\" & sMonthNo & sYearNo & "\"
MkDir sNewDir
End If

It first checks to see if it exists already and if not creates the new directory. However on the MkDir command I'm getting the error 76 - Path Not Found. But of course it's not found, its supposed to be creating it. Is this error due to the directory being too long, or something else? If so, is there another way of implementing this?
 
In a standard code module create the following function:
Code:
Sub myMkDir(strFolderName As String)
On Error Resume Next
Dim a, t As String, i As Integer
a = Split(strFolderName, "\")
t = a(0)
For i = 1 To UBound(a)
  t = t & "\" & a(i)
  MkDir t
Next
End Sub

Then replace this:
MkDir sNewDir
with this:
myMkDir sNewDir

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Cheers for the code PH, however its not recognising the command Split? Is that another sub and if so what is the code behind it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top