Hi Dave,
If all the files have the same structure and are to be imported into the
same table, it's often simplest to concatenate them into one big file
and import that. At a command prompt, use something like this to
concatenate them:
COPY /B "D:\Folder\*.txt" "D:\Folder\All files.txt"
Alternatively, use code like this (acknowledgements to Joe Fallon) to
import each file individually:
Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String
ChDir ("D:\Folder")
strfile = Dir("*.txt")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, _
"ImportSpecName", "AccessTableName", _
"D:\Folder\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "D:\Folder\" & strfile
strfile = Dir
Loop
End Sub
I have a folder of 50+ tab deliminated text files I want
to import into Access. Do I have to do this one file at a
time or is there a way to batch process the files.
Thanks in anticipation
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.