Question : Renaming a Column using Code

Hi!
I am trying to use code in Access2000 to change the name of a field in a table with little success. Any input of how to do this would be greatly appreciated.

This is what I have so far.

Function Change_Name()

   DoCmd.OpenTable "myTable", acNormal, acEdit
   DoCmd.GoToControl "TimeVisit"
   DoCmd.RunCommand acCmdRenameColumn

End Function


I tried adding acCmdRenameColumn ("TimeVisit", "test")
but this did not work. After this line I would also include an other line to save and close the table but I left that out for now.

Thankssssssss.

Answer : Renaming a Column using Code

If you have a reference to DAO (open a code module, click Tools->Reference and make sure Microsoft DAO 3.6 is ticked), try this single line:
CurrentDb.TableDefs("myTable").Fields("TimeVisit").Name="test"
Random Solutions  
 
programming4us programming4us