This code will import all the CSV files from a Folder.
Note that this VBA is run from a form which has a field called Filepath which is used to identify which folder you want to use, you could replace the me.Filepath with the actual path to your folder.Dim FileNm, FilePathName, Path, FileNameList() As String Dim FileCount As Integer DoCmd.SetWarnings False Path = Me.FilePath FileNm = Dir(Path & "") Search_path = Path ' where ? Search_Filter = "*.CSV" ' what ? Docname = Dir(Search_path & "" & Search_Filter) Do Until Docname = "" ' build the collection MsgBox Docname FilePathName = Path & Docname DoCmd.TransferText transferType:=acImportDelim, SpecificationName:="pp OUTINGS", TableName:="pp OUTINGS", FileName:=FilePathName, hasfieldnames:=True Docname = Dir Loop DoCmd.SetWarnings True MsgBox "Updates Complete" Exit Sub errorcatch: MsgBox Err.Description
Also the DoCmd.TransferText has an Import specification called "pp OUTINGS" which you will not need unless you have an import spec.
The data is then placed in a table called "pp OUTINGS"
Try this code by modifying it to suit your folder and table and then repost if you do so.




Reply With Quote