Consulting

Results 1 to 2 of 2

Thread: Create Folders based on a Form Range Help with second round of folder creation

  1. #1
    VBAX Regular
    Joined
    Jul 2017
    Posts
    18
    Location

    Create Folders based on a Form Range Help with second round of folder creation

    Hi,

    Attached is a database program which allows scan operator to create a bunch of sequentially numbered subfolders.

    Select User Warren Nelson, Password is Welcome.

    The beginning pathway exists in the table t_User_Scan_Paths, and a TempVars is set to the path for the logged on user.

    While I can get the original range of folders created, if the scanner realizes they need more folders than were originally created, I would like to be able to add that range of folders, too.

    The Form is f_Create_Folder_Structures, and here is the command button named cmd_Create_Folder_Structure On Click Event...


    Option Compare Database
    Option Explicit
    Private Sub Form_Load()
      Me.txt_Main_Scan_Path = TempVars!ScanPath
    End Sub
    Private Sub cmd_Create_Folder_Structure_Click()
      Dim strBaseFolder As String
      Dim strFolder     As String
      Dim i             As Integer
    On Error GoTo ProcErr
      strBaseFolder = TempVars!ScanPath
      strBaseFolder = _
        strBaseFolder & _
        "\" & Format(Date, "yyyy\-mm\-dd") ' This is an example of how other levels could be added
      If CheckPath(strBaseFolder) = False Then
          MsgBox "The base path could not be created." & vbNewLine & _
                  "Be sure the path does not end with a backslash."
          Exit Sub
      End If
      For i = Val(Me.[txt_Start_Folder_Number]) To Val(Me.[txt_End_Folder_Number])
        strFolder = strBaseFolder & "\" & i
        If FolderExists(strFolder) Then
            MsgBox strFolder & " already exists."
          Else
            MkDir strFolder
        End If
      Next i
    EndProc:
      Exit Sub
    ProcErr:
      MsgBox "Error " & Err.Number & "(" & Err.Description & ") in cmd_Create_Folder_Structure_Click"
      Resume EndProc
    End Sub
    I am very new to VBA so any help would be greatly appreciated !!!

    Thanks you,

    Bill
    Attached Files Attached Files

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Hello again.
    You haven't said what is or is not working

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •