nikkai
To transfer from the spreadsheet file. Research TransferText or TransferSpreadsheet for options and usage.
DoCmd.TransferText acImportDelim, , NewTable, Source.csv
OR
DoCmd.TransferSpreadsheet acImport, , NewTable, Source.xls
For 300+ files...
Use the FSO (you may have to add the reference, Alt-F11 for VB coding window, then from the menu, "Tools" -> "References" and "look for Microsoft Scripting Runtime")
Following code loads a combo box with a list of files in a folder.
Code:
Dim fso As Scripting.FileSystemObject
Dim fso_folder As Folder
Dim fso_file As File
Dim dir_path As Folder
Dim strFilepathFrom As String
'From the form
strFilepathFrom = Nz(Me.txtFileLocation,"")
strFiles = ""
If Len(strFilepathFrom) Then
Set fso = New FileSystemObject
Set fso_folder = fso.GetFolder(strFilepathFrom)
If fso.FolderExists(strFilepathFrom) Then
For Each fso_file In fso_folder.Files
strFiles = strFiles & ";" & Nz(fso_file.Name, "")
Next fso_file
strFiles = Right(strFiles, Len(strFiles) - 1)
If Len(strFiles) Then
Me.cmbFileName.RowSource = strFiles
End If
End If
Set fso = Nothing
End If
Instead of loading the combo box, you should be able to use the TransferSpreadsheet or TransferText method.
A gotcha -- the spreadsheet has to have the same format / fields, and is not forgiving with bad data. Troubleshooting a run time data error on the Tranfer method can be problematic, for me anyway.
Richard