Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / April 2008

Tip: Looking for answers? Try searching our database.

Rename a field in a table

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 15 Apr 2008 01:24 GMT
Hi,

Via code how do I rename a field in a table (Tbl_Table) from
Original_Filedname to New_Fieldname?

Signature

Andrew
150408

Dirk Goldgar - 15 Apr 2008 01:42 GMT
> Hi,
>
> Via code how do I rename a field in a table (Tbl_Table) from
> Original_Filedname to New_Fieldname?

You can do it via DAO.  For example:

   Dim db As DAO.Database
   Dim tdf As DAO.TableDef

   Set db = CurrentDb
   Set tdf = db.TableDefs("Tbl_Table")
   tdf.Fields("Original_FieldName").Name = "New_FieldName"

Or, in a shorter form:

   CurrentDb.TableDefs("Tbl_Table").Fields("Original_FieldName").Name = _
           "New_FieldName"

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Andrew - 15 Apr 2008 02:34 GMT
Thanks Dirk for your timely, informative and accurate answer.
Signature

Andrew

> > Hi,
> >
[quoted text clipped - 14 lines]
>     CurrentDb.TableDefs("Tbl_Table").Fields("Original_FieldName").Name = _
>             "New_FieldName"
fredg - 15 Apr 2008 02:15 GMT
> Hi,
>
> Via code how do I rename a field in a table (Tbl_Table) from
> Original_Filedname to New_Fieldname?

DoCmd.Rename "NewTableName", acTable, "OldTableName"
Signature

Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Andrew - 15 Apr 2008 02:35 GMT
Thanks fredg but I wanted to rename fieldnames - Dirk provided the answer in
the above thread.
Signature

Andrew

> > Hi,
> >
> > Via code how do I rename a field in a table (Tbl_Table) from
> > Original_Filedname to New_Fieldname?
>
> DoCmd.Rename "NewTableName", acTable, "OldTableName"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.