I use the below code to cycle through entries in a table and import the corresponding CSV file into my Temp table in a database. The issue I'm having is that it starts with record number 2, instead of the first record.
My fields in the db are Path (eg C:\Form Downloader\25102015\ALFIE'S ROSE.csv) and FileName (eg ALFIE'S ROSE). Can anyone see where I'm going wrong? It also seems to be skipping records and not importing them as well.
Code:Option Compare Database Sub Import_Data_ListNamesA() DoCmd.SetWarnings False Dim d As DAO.Database Dim r As DAO.Recordset Dim intI As Integer Dim LstFileNamesA As Field, Path As Field, FileName As Field Set d = CurrentDb() Set r = d.OpenRecordset("LstFileNamesA") Set DogForm = r.Fields("Path") Set DelErrorTable = r.Fields("FileName") While Not r.EOF DoCmd.SetWarnings False DoCmd.TransferText TransferType:=acDelim, TableName:="tbl_TEMP_A", FileName:=DogForm, HasFieldNames:=True On Error Resume Next DoCmd.DeleteObject acTable, DelErrorTable & "_ImportErrors" Err.Clear DoCmd.SetWarnings True r.MoveNext Wend r.Close DoCmd.SetWarnings True MsgBox "Complete" End Sub


Reply With Quote

