Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2006

Tip: Looking for answers? Try searching our database.

MkDir  won't create a directory and sub directory at the same time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pubdude2003 - 14 Dec 2006 13:00 GMT
For instances where my FolderPath value is "C:\MyQuotation\Jan" it won't
create the directory. Is there something I can do to correct the code?

   Dim Path As String
   
   If Not IsNull(DLookup("FolderPath", "UserPass")) Then
   Path = (DLookup("FolderPath", "UserPass"))
   End If
   
   If Dir(Path, vbDirectory) = "" Then
   MkDir Path
   End If
   
  Dim strLinkPath As String
  Dim objShell As Object

  If Path = "" Then
  Set objShell = CreateObject("WScript.Shell")
  strLinkPath = objShell.SpecialFolders("MyDocuments")
  Else
  strLinkPath = Path
  End If
OfficeDev18 - 14 Dec 2006 19:55 GMT
Sorry, but "Path" is a valid Access property, otherwise called a "reserved
word." You cannot use reserved words as variable names. Change all instances
of the standalone word "Path" and try your program again.

Sam

>For instances where my FolderPath value is "C:\MyQuotation\Jan" it won't
>create the directory. Is there something I can do to correct the code?
[quoted text clipped - 18 lines]
>   strLinkPath = Path
>   End If

Signature

Sam

pubdude2003 - 22 Dec 2006 15:26 GMT
Thanks Dev, didn't know that, although the code did work for single dir
creation.

At any rate here is the code for multiple dir

   Dim strPath  As String
      Dim aFolders() As String
  Dim I As Integer
   
   If Not IsNull(DLookup("FolderPath", "UserPass")) Then
   strPath = (DLookup("FolderPath", "UserPass"))
   End If
   
   If Dir(strPath, vbDirectory) = "" Then

  If Len(strPath) = 0 Then
      Err.Raise 5
      Exit Sub
  End If

  aFolders = Split(strPath, "\")
  strPath = vbNullString

  For I = LBound(aFolders) To UBound(aFolders)
      strPath = strPath & aFolders(I)
      If Len(Dir(strPath, vbDirectory)) = 0 Then
          MkDir strPath
      End If
      strPath = strPath & "\"
  Next I
   
   End If
pubdude2003 - 22 Dec 2006 15:26 GMT
Thanks Dev, didn't know that, although the code did work for single dir
creation.

At any rate here is the code for multiple dir

   Dim strPath  As String
      Dim aFolders() As String
  Dim I As Integer
   
   If Not IsNull(DLookup("FolderPath", "UserPass")) Then
   strPath = (DLookup("FolderPath", "UserPass"))
   End If
   
   If Dir(strPath, vbDirectory) = "" Then

  If Len(strPath) = 0 Then
      Err.Raise 5
      Exit Sub
  End If

  aFolders = Split(strPath, "\")
  strPath = vbNullString

  For I = LBound(aFolders) To UBound(aFolders)
      strPath = strPath & aFolders(I)
      If Len(Dir(strPath, vbDirectory)) = 0 Then
          MkDir strPath
      End If
      strPath = strPath & "\"
  Next I
   
   End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.