Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing multiple txt files into Access 1

Status
Not open for further replies.

MattBegg

Programmer
Jan 19, 2001
42
CA
How could I go about importing many csv files into an Access 2000 database all with the same structure but there is no commonality between the files names, onlt the extension.

I would imagine the logic would be to loop through each file in the directory until all have been processed, but at the moment I cannot think of the code, any help would be much appreciated. Regards

Matt

matt@begg-uk.co.uk
 

Private Function importAll()
On Error GoTo err
FileSearch.NewSearch
FileSearch.FileName = "*.csv"
FileSearch.MatchTextExactly = False
FileSearch.SearchSubFolders = False
FileSearch.LookIn = "c:\imports"
FileSearch.Execute
For i = 1 To FileSearch.FoundFiles.Count
DoCmd.TransferText acImportDelim, , "Table1", FileSearch.FoundFiles(i), False
Next
ex:
Exit Function
err:
MsgBox Error$
Resume ex
End Function

May need to check the TransferText bit, and haven't bothered to test it, but try that. Ben
+61 403 395 052
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top