Here is some code that should do that. It borrows a new User Defined Functions from Allen Browne's site (see: http://allenbrowne.com/func-11.html).
Code:
Private Sub Createcmd_Click()
Dim startPath As String
Dim finalPath As String
' Enter starting path prefix
startPath = "C:\Users\General\Desktop"
' Check to see if Code_Id entered
If IsNull(Me.Code_Id) Then
MsgBox "No Code ID entered"
Else
' Build final path string
finalPath = TrailingSlash(startPath) & Me.Code_Id
' Check to see if folder already exists
If FolderExists(finalPath) Then
MsgBox "The following path already exists:" & vbCrLf & finalPath
Else
' If not, create it
On Error GoTo err_check
MkDir finalPath
MsgBox "Successfully created folder: " & vbCrLf & finalPath
On Error GoTo 0
End If
End If
Exit Sub
' Error message to return if folder name is not valid
err_check:
MsgBox finalPath & " is not a valid folder name."
End Sub
Function FolderExists(strPath As String) As Boolean
' From http://allenbrowne.com/func-11.html
On Error Resume Next
FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
End Function
Function TrailingSlash(varIn As Variant) As String
' From http://allenbrowne.com/func-11.html
If Len(varIn) > 0 Then
If Right(varIn, 1) = "\" Then
TrailingSlash = varIn
Else
TrailingSlash = varIn & "\"
End If
End If
End Function