Hello all, hope that you are having a Great Day!
I hopeing that someone could help me with a Loop problem. I am trying to create a directory on each name change. My code works for the first name, however, when I am trying to Loop through the table, it isn't working.
Here is my code
'MkDir "H:\NewPrivateFolder"
On Error GoTo Err_cmbMkDir_Click
Dim DirName As String
Dim response As String
Dim folder As String
folder = "H:\Projects\"
'Forms("form1").Controls("list1").MultiSelect = 2
'DLookup("Officers_Name", "tblOfficers")
DirName = folder & DLookup("officers_name", "tblofficers")
Do
If Dir(DirName, vbDirectory) = "" Then
If MsgBox("OK to create folder!", vbOKCancel) = vbOK Then
MkDir DirName
Else
MsgBox "Create folder cancelled. Folder not created."
Exit Sub
End If
Else
MsgBox "The folder already exists..." & Chr(10) & "Please check the directories using Windows Explorer.", vbOKOnly
Exit Sub
End If
'response = MsgBox(DirName, vbOKOnly)
Loop
Exit_cmbMkDir_Click:
Exit Sub
Err_cmbMkDir_Click:
MsgBox Err.Description
Resume Exit_cmbMkDir_Click
End Sub
I hopeing that someone could help me with a Loop problem. I am trying to create a directory on each name change. My code works for the first name, however, when I am trying to Loop through the table, it isn't working.
Here is my code
'MkDir "H:\NewPrivateFolder"
On Error GoTo Err_cmbMkDir_Click
Dim DirName As String
Dim response As String
Dim folder As String
folder = "H:\Projects\"
'Forms("form1").Controls("list1").MultiSelect = 2
'DLookup("Officers_Name", "tblOfficers")
DirName = folder & DLookup("officers_name", "tblofficers")
Do
If Dir(DirName, vbDirectory) = "" Then
If MsgBox("OK to create folder!", vbOKCancel) = vbOK Then
MkDir DirName
Else
MsgBox "Create folder cancelled. Folder not created."
Exit Sub
End If
Else
MsgBox "The folder already exists..." & Chr(10) & "Please check the directories using Windows Explorer.", vbOKOnly
Exit Sub
End If
'response = MsgBox(DirName, vbOKOnly)
Loop
Exit_cmbMkDir_Click:
Exit Sub
Err_cmbMkDir_Click:
MsgBox Err.Description
Resume Exit_cmbMkDir_Click
End Sub