Hey,
As i had posted about transfer spreadsheet before, and i was able get my form to properly import using that method. I have been trying to manipulate it in using it as a Loop. Now i have The same file names that i would be importing on a regular basis. The trick is that It would save me time to do it in a Loop, so i only have to do one step instead of repeating the step 7 times. Now, I have my form set up for cases, you select case 1, 2 or 3. i call a specified function. so for case 3 i developed this code:
Code:
Function txtImportstring()
On Error GoTo Import_Err
Dim strFilter As String
Dim strInputFileName As Variant
Dim strtblname As Variant
For Each strtblname In CurrentProject(Array("Address_Information", "Portfolio_Manager_Section", "Fund_Strategy_Section", "Risk_Management", "Service_Providers", "Investment_Desicion", "Supporting Documents"))
Dim strFolderName As String
Call GetFolder
For Each strInputFileName In CurrentProject(Array("Address Information.CSV", "Portfolio Manager_Section.CSV", "Fund Strategy Section.CSV", "Risk Management.CSV", "Service Providers,CSV", "Investment Desicion.CSV", "Supporting Documents.CSV"))
If Len(strInputFileName) > 0 Then
DoCmd.TransferText acImportDelim, actextTypeCSV12, strtblname, strInputFileName, True, ""
End If
If Len(strInputFileName) > 0 Then
MsgBox "Imported strtblename"
End If
Next strInputFileName
Next strtblname
Import_Exit:
Exit Function
Import_Err:
MsgBox Error$
Resume Import_Exit
End Function
Code:
Function GetFolder()
Dim SA As Object
Dim f As Object
Set SA = CreateObject("Shell.Application")
Set f = SA.BrowseForFolder(0, "choose a folder", 16 + 32 + 64, strStarDIR)
If (Not f Is Nothing) Then
PickFolder = f.items.Item.path
End If
Set f = Nothing
Set SA = Nothing
End Function
Now the error i get is 'the object doesn't support this property or method'
Also, When i get the folder path, i do not know how to get the path to come in for strFileName to see that is the folder to get the files i have listed in the Array.
The objective is to click, my button, and then it prompts me to select the folder where the files are located. I have it set up as an array. Now when i do it individually meaning, i select the table from my combobox, then i prompt for file, and run the same transfer text code as above, it works great. But instead of doing it 7 times individually i want to do it all in one go, so i have been manipulating the code into what i currently have to do the loop. Thanks for the help in the advance,