title: Automating MS Access to upload/Export files and merge into a table
body: <p>I have this code that imports a csv file into an Access table.
  There are several problems or ideas that are beyond my level of skills.
  The first issue is the file does not append existing fields, instead the entire file is inserted create a duplicate including new headers.</p>
  
  <p>The second issue is I would like to export only new or updated records in a csv file out of Access, not the entire table, I have not gotten there yet.</p>
  
  <p>I need a little hand holding here.</p>
  
  <p>Thank you everyone, this forum and you guys are the best. Always helpful and wailing to share your knowledge.</p>
  
  <pre><code>Option Compare Database
  Option Explicit
  
  Private Sub ImportFile()
  Dim strPathFile As String, strFile As String, strPath As String
  Dim strTable As String
  
  Dim xlApp As Object, xlWb As Object, xlWs As Object
  Dim lngRow As Long, lngLastRow As Long
  Dim rst As DAO.Recordset
  
  strPath = "C:\Transit\"
  strTable = "Transit"
  strFile = Dir(strPath &amp; "*.csv")
  
  Set rst = CurrentDb.OpenRecordset(strTable)
  
  Do While Len(strFile) &gt; 0
  
        strPathFile = strPath &amp; strFile
  
          Set xlApp = CreateObject("Excel.Application")
          Set xlWb = xlApp.Workbooks.Open(strPathFile)
          Set xlWs = xlWb.Worksheets(1)
  
          lngLastRow = xlWs.UsedRange.Rows.Count
  
          For lngRow = 1 To lngLastRow
  
              rst.AddNew
              rst("Field1") = xlWs.Range("A" &amp; lngRow).Value
              rst("Field2") = xlWs.Range("B" &amp; lngRow).Value
              rst("Field3") = xlWs.Range("C" &amp; lngRow).Value
              rst("Field4") = xlWs.Range("D" &amp; lngRow).Value
              rst("Field5") = xlWs.Range("E" &amp; lngRow).Value
              rst("Field6") = xlWs.Range("F" &amp; lngRow).Value
              rst("Field7") = xlWs.Range("G" &amp; lngRow).Value
              rst.Update
  
          Next
  
      xlApp.Quit
      Set xlApp = Nothing
      Set xlWb = Nothing
      Set xlWs = Nothing
      strFile = Dir()
  Loop
  
  rst.Close
  Set rst = Nothing
  
  End Sub
  </code></pre>