PDA

View Full Version : Create Folders based on a Form Range Help with second round of folder creation



Oblio
11-11-2017, 09:57 AM
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

OBP
11-12-2017, 05:35 AM
Hello again.
You haven't said what is or is not working