• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1178
  • Last Modified:

Modify-change field name

How do I modify-change the name of a field in a table using ADO-ADOX? I have tried the following code but it does not work:

     Table.Columns(ColumnParadox.Name).Name = Replace(ColumnParadox.Name, "#", "")
     Table.Columns.Item(ColumnParadox.Name).Name = Replace(ColumnParadox.Name, "#"

    Table is defined as an ADOX Table (ADOX.Table)
0
pancho_alvarez
Asked:
pancho_alvarez
1 Solution
 
Rey Obrero (Capricorn1)Commented:
try this sub

Sub changeFldName(xT As String)
Dim tbl As ADOX.Table
Dim cat As New ADOX.Catalog, j
Set cat.ActiveConnection = CurrentProject.Connection
For j = 0 To cat.Tables(xT).Columns.Count - 1
    If InStr(cat.Tables(xT).Columns(j).Name, "#") Then
        cat.Tables(xT).Columns(j).Name = Replace(cat.Tables(xT).Columns(j).Name, "#", "")
    End If
   
Next
End Sub


to use pass the name of the table

changeFldName("nameOfTable")


0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now