title: using vba to change field name in access 2007
body: <p>I receive data monthly from an external company and need to change the field name to a sequential number. example contract 11 15 17 to 1 2 3. I am trying to use the following code but get an error that I cannot define the field more than once at "fld.Name = (n) + 1". How can I correct this?</p>
  
  <pre><code>Function ChangeFieldName()
  
  Dim db As DAO.Database
  Dim tbl As DAO.TableDef
  Dim fld As DAO.Field
  Dim n As Integer
  
  Set db = CurrentDb
  Set tbl = db.TableDefs("tdf1")
  
  On Error Resume Next
  
  n = 0
  For Each fld In tbl.Fields
      fld.Name = (n) + 1
  Next fld
  
  Set fld = Nothing
  Set tbl = Nothing
  Set db = Nothing
  
  End Function
  </code></pre>