Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing column name using code

Status
Not open for further replies.

rocco

IS-IT--Management
Oct 30, 2001
106
CA
I would like to change the field name of a table using code.
So far this is what I have but I am stuck.

function Change_field_name()

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

End Function

I tried adding acCmdRenameColumn ("TimeVisit","ImpDate")
but it did not work. Any help would be greatly appreciated thanksss everyone.
 
Rocco,
I goofed around and was able to get it to work this way.

Dim tblTest As ADOX.Table
Dim col As ADOX.Column
Dim cat As ADOX.Catalog

Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
Set tblTest = cat.Tables.Item("myTable")

Set col = tblTest.Columns.Item("TimeVisit")
col.name = "test"

You'll need to make a reference to "Microsoft ADO Extension"
Let me know if you have any problems.
Thanks,


Chris
 
Thank you Chris for your response...
I tried this line and it worked beautifulllly.

Microsoft DAO 3.6 has to be ticked - below all in one line

CurrentDb.TableDefs("myTable").Fields ("TimeVisit").Name="test"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top