I have a cbox (cboBizYear) bound to 'BizYear' on an Access 2007 form. I want the value selected (eg., 'nn_R11_TY-yy) to be used to be the name of the folder to be created, with 'Marketing' as a sub-folder. Here is my code:
Private Sub cboBizYear_Click()
Dim strFolder_Path As String
Dim BizYear As String
Dim strWhere As String
'Captures the user selected 'BizYear'
strWhere = "[BizYear] =" & Chr(34) & Me.[cboBizYear] & Chr(34)
Debug.Print strWhere 'Displays: '[BizYear] ="12_R11_TY-18" in the IA Window, for this example selection.
'Creates path for folder & sub-folder to hold files
strFolder_Path = "C:\strWhere" & "\" & "Marketing\"
Debug.Print strFolder_Path 'Displays: 'C:\strWhere\Marketing\'; NOT 'C:\12_R11_TY-18\Marketing\
'Check for existing directory
If Dir(strFolder_Path, vbDirectory) = "" Then
MsgBox ("Ok to create folder!"), vbOKCancel = vbOK
MkDir strFolder_Path
Else
MsgBox "The folder already exists.", vbOKOnly
End If
End Sub
Private Sub cboBizYear_Click()
Dim strFolder_Path As String
Dim BizYear As String
Dim strWhere As String
'Captures the user selected 'BizYear'
strWhere = "[BizYear] =" & Chr(34) & Me.[cboBizYear] & Chr(34)
Debug.Print strWhere 'Displays: '[BizYear] ="12_R11_TY-18" in the IA Window, for this example selection.
'Creates path for folder & sub-folder to hold files
strFolder_Path = "C:\strWhere" & "\" & "Marketing\"
Debug.Print strFolder_Path 'Displays: 'C:\strWhere\Marketing\'; NOT 'C:\12_R11_TY-18\Marketing\
'Check for existing directory
If Dir(strFolder_Path, vbDirectory) = "" Then
MsgBox ("Ok to create folder!"), vbOKCancel = vbOK
MkDir strFolder_Path
Else
MsgBox "The folder already exists.", vbOKOnly
End If
End Sub