Function ImportCSVFiles()
Dim FilesToProcess As Integer
Dim i As Integer
Const TOP_FOLDER = "G:\MSAccessTesting" 'adjust folder name to suit
Const ARCHIVE_FOLDER = "G:\MSAccessTesting\Imported" 'adjust folder name to suit
Const DEST_TABLE = "tbl_Daily_RMT" 'change to suit
Const IMPORT_SPEC = "DAILYRMT.csv" 'change to suit
With Application.FileSearch
.NewSearch
.LookIn = TOP_FOLDER
.SearchSubFolders = False 'we only want to search the top folder
.Filename = "*.csv"
.Execute
FilesToProcess = .foundfiles.Count
For i = 1 To FilesToProcess
'import each file
DoCmd.TransferText acImportDelim, IMPORT_SPEC, DEST_TABLE, .foundfiles(i), True
Next i
End With
End Function
Function ImportOneCSVFile()
Dim FilesToProcess As Integer
Dim i As Integer
Const IMPORT_SPEC = "The name of your import spec" 'change to suit
Const DEST_TABLE = "tbl_Daily_RMT" 'change to suit
Const IMPORT_FILE = "G:\MSAccessTesting\DailyRMT.csv" 'adjust to suit; full path to file
'import the file
DoCmd.TransferText acImportDelim, IMPORT_SPEC, DEST_TABLE, IMPORT_FILE, True
End Function
DoCmd.TransferText acImportDelim, , DEST_TABLE, IMPORT_FILE, True
DoCmd.SetWarnings False
DoCmd.Execute "yourDeleteQuery"
'run your import code in here, then...
DoCmd.Execute "yourAppendQuery"
DoCmd.SetWarnings True