I keep getting an error "Could not find object". Then it references the file CAPCMS08062012. which is the first file in the folder.
I modified this code from an example I got on this "AWESOME" site. I really mean that!
I have multiple files to import on a regular basis. This would save me a great deal of time.
Thanks
Rich1968
Option Compare Database
Function Load_Core_Data()
Dim NextFile, ImportFile, FileCriteria, ctr As Variant
FileCriteria = "C:\Core\*.CSV"
' create field with path and filename to import'
NextFile = Dir(FileCriteria)
' Check we have something to import
If NextFile = "" Then
MsgBox "No files to import", , "Error"
Exit Function
End If
ctr = 0
' Import each file that meets the criteria '*.CSV'
While NextFile <> ""
' count files imported
ctr = ctr + 1
' add the path to the returned filename
ImportFile = FileCriteria & NextFile
' Import file into table
DoCmd.TransferText acImport, , "Core Import Specfication", ImportFile, True
' get another file if it exists
NextFile = Dir()
Wend
MsgBox ctr & " files imported", , "Core Data Import"
End Function
I modified this code from an example I got on this "AWESOME" site. I really mean that!
I have multiple files to import on a regular basis. This would save me a great deal of time.
Thanks
Rich1968
Option Compare Database
Function Load_Core_Data()
Dim NextFile, ImportFile, FileCriteria, ctr As Variant
FileCriteria = "C:\Core\*.CSV"
' create field with path and filename to import'
NextFile = Dir(FileCriteria)
' Check we have something to import
If NextFile = "" Then
MsgBox "No files to import", , "Error"
Exit Function
End If
ctr = 0
' Import each file that meets the criteria '*.CSV'
While NextFile <> ""
' count files imported
ctr = ctr + 1
' add the path to the returned filename
ImportFile = FileCriteria & NextFile
' Import file into table
DoCmd.TransferText acImport, , "Core Import Specfication", ImportFile, True
' get another file if it exists
NextFile = Dir()
Wend
MsgBox ctr & " files imported", , "Core Data Import"
End Function