I have a couple of nested IF statements here, all seems to work ok but just wondered if I have my "End If" statements in the correct place.
Just don't want it falling over when I'm on my holidays next week.
Code: Select all
Private Sub cmdNewFolder_Click()
Dim strNewFolder As String
strNewFolder = "L:\MMPDF\ConsoleFiles\" & Me.txtEst & "\"
If Me.txtEst.Text = "" Then
MsgBox "You Cannot Use This Function Unless You" & vbCrLf & "Specify A Valid Job Number", vbInformation, "Create Folder"
Exit Sub
Else
If Dir(strNewFolder, vbDirectory) = "" Then
MkDir strNewFolder
If MsgBox("New Folder Created For Job Number " & Me.txtEst.Text & vbCrLf & _
" Do You Want To Open The Folder?", vbYesNo + vbQuestion, " Folder Created") = vbYes Then
'MsgBox "New Folder Created For Job Number " & Me.txtEst & vbCrLf & _
' "Your New Folder Will Now Open", vbInformation, "New Folder"
With CmnDialog1
'~~> Set the Title of the Dialog Box
.DialogTitle = "Open New Folder"
'~~> Set the Initial directory
.InitDir = "L:\MMPDF\ConsoleFiles\" & Me.txtEst.Text & "\"
'~~> Set the Filter for the files that you want to open
.FileName = ""
.Filter = "All Files (*.*)"
'~~> Displays the Open Dialog Box
.ShowOpen
End With
End If
Else
If MsgBox("Folder " & Me.txtEst & " Already Exists " & _
" Do You Want To View The Folder And It's Contents !!?", vbYesNo + vbQuestion, " Folder Exists") = vbYes Then
With CmnDialog1
'~~> Set the Title of the Dialog Box
.DialogTitle = "Open New Folder"
'~~> Set the Initial directory
.InitDir = "L:\MMPDF\ConsoleFiles\" & Me.txtEst.Text & "\"
'~~> Set the Filter for the files that you want to open
.FileName = ""
.Filter = "All Files (*.*)"
'~~> Displays the Open Dialog Box
.ShowOpen
End With
End If
End If
End If
End Sub