I am teying to test to see if a directory and sub directory exists on my C drive and if it does not then create the directory using the variable Me.FileNo as the name.
The Mkdir function works and the directory is created as expected when I run the the procedure the first time. The problem is the second time I run the procedure it tries to create a duplicate director and I get a run time error. So I must have something wrong with the If then statement. Can anone help me. I am a beginner with VBA.
Here is the code:
Private Sub CmdMakeDir_Click()
If Dir("C:\Client Data" & "\" & Me.[FileNo]) = "" Then
MkDir "C:\Client Data" & "\" & Me.[FileNo]
End If
End Sub
The Mkdir function works and the directory is created as expected when I run the the procedure the first time. The problem is the second time I run the procedure it tries to create a duplicate director and I get a run time error. So I must have something wrong with the If then statement. Can anone help me. I am a beginner with VBA.
Here is the code:
Private Sub CmdMakeDir_Click()
If Dir("C:\Client Data" & "\" & Me.[FileNo]) = "" Then
MkDir "C:\Client Data" & "\" & Me.[FileNo]
End If
End Sub