Hello:
I use a VBA routine to import Excel files into an Access table. As of right now, the file path (where XLSX files are stored), is hard-coded. I want it to remain this way!
See below where I define the constant value for the path. It works great!
Code:
Const strPath As String = "C:\Users\..\Import_Files_All\"
The only modification is that I now want to import different XLSX files based on a selected radio button (value).
To accomplish this, I added string "strWhichPath".
Next, depending on the radio button, I intend to pass that value into the *Const strPath*.
Unfortunately, I now get an error indicating a compile error (see attached JPG).
Code:
Dim strWhichPath As String
Select Case Forms![FormName].optValidationRecordSet.Value
'Append all records
Case "1":
strWhichPath = "Import_Files_All"
'Append record subset #1
Case "2":
strWhichPath = "Import_Files_Subset1"
'Append record subset #2
Case "3":
strWhichPath = "Import_Files_Subset2"
End Select
Const strPath As String = "C:\Users\..\" & strWhichPath & "\"
My question: How do I need to modify the Const strPath OR SELECT CASE in order to pass the variable into it AND to not receive the compile error?