Hi all,
I currently have a button on a form which, when clicked, I would like to do several things:
1) Check if the folder, "folder name (1)" exists
2) If no, make it; if yes, check if the folder, "folder name (2)" exists
3) If no, make it; if yes, check if the folder, "folder name (3)" exists
4) repeat this process until a new folder is made
The code I currently have seems to not work, and makes an infinite loop
This probably won't take you very long, but I've been puzzling over it for ages so any help is appreciated!
TIA
I currently have a button on a form which, when clicked, I would like to do several things:
1) Check if the folder, "folder name (1)" exists
2) If no, make it; if yes, check if the folder, "folder name (2)" exists
3) If no, make it; if yes, check if the folder, "folder name (3)" exists
4) repeat this process until a new folder is made
The code I currently have seems to not work, and makes an infinite loop
Code:
Private Sub Export_Click()
Dim checker As Integer
Dim projPath As String
checker = 1
projPath = CurrentProject.path & "\Exported Data " & Day(Date) & " " & MonthName(Month(Date)) & " " & Year(Date) & " (" & checker & ")"
If Len(Dir(projPath, vbDirectory)) = 0 Then
MkDir projPath
Else
Do While Len(Dir(projPath, vbDirectory)) <> 0
checker = checker + 1
If Len(Dir(projPath, vbDirectory)) = 0 Then
MkDir projPath
End If
Loop
End If
End Sub
This probably won't take you very long, but I've been puzzling over it for ages so any help is appreciated!
TIA