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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Importing multiple .csv files into db table 1

Status
Not open for further replies.

n4nz

Technical User
Jul 20, 2006
3
GB
Hi guys, I am trying to import multiple .csv files into one table using DoCmd.TransferText acImportDelim, I have no problems with one csv file but I want it to loop so that the contents of a directory specified containing all .csv files are imported or appended.

Thanks in advance
 
Have a look at the Dir function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Ok here's the code i'm trying to use, however when run the Dir picks up the file name no problem, but then i get an Jet database Engine error telling me that it can't find the object 1.csv (which happens to be the file)

Function ImportCSV()

Dim ImportFile
ImportFile = Dir("d:\test\*.csv")
Do While ImportFile <> ""

DoCmd.TransferText acImportDelim, "", "TestImport", ImportFile, False, ""
ImportFile = Dir

Loop

End Function
 
DoCmd.TransferText acImportDelim, "", "TestImport", [!]"d:\test\" & [/!]ImportFile, False, ""

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Many thanks, now works a treat..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top