Problem:
How do I change the field name of a table?
Jet SQL can change the field type, could you change the name of the field with Jet SQL?
Reply:
Jet SQL cannot change field names unless you use several Jet SQL to delete the field and then insert the word
section, and then use the update query to restore the original field data for the saved temporary table.
Alternatively, you can change the Name property of the TABLE's Columns (field name) object directly with ADOX.
Function Test ()
Changetablefieldname_ado "Table 1", "AA", "Pic1"
End Function
Function Changetablefieldname_ado (Mytablename As String, Myfieldname as String, strNewName as String)
' 3 parameters:
' Mytablename string, table name
' Myfieldname string, original field name
' strNewName string, new field name
' Remember to quote ADOX first
Dim MyDB as New ADOX. Catalog
Dim MyTable as ADOX. Table
Mydb.activeconnection = CurrentProject.Connection
Set MyTable = mydb.tables (mytablename)
Mytable.columns (Myfieldname). Name = strNewName
End Function