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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming a field in VBA using SQL??

Status
Not open for further replies.

satchi

Programmer
Sep 15, 2003
104
US
Hi, I was wondering if it's possible to rename a field in Access using SQL statements? I'm using access databases and would like to rename a field of a table remotely. Thanks
 
What is the business case of changing the name of a column in a table ?
Who cares ?
Anyway, have a look at the DAO.TableDef.Field object (the Name property).
BTW, there is no SQL way I'm aware of, but VBA.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
VBScript may be useful.
Code:
Set catTables=CreateObject("ADOX.Catalog")

Set cn = CreateObject("ADODB.Connection")
dbfile = "C:\Docs\Tek-Tips.mdb"

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
     "Data Source=" & dbfile & ";"

Set catTables.ActiveConnection = cn

catTables.Tables("tblTable").Columns("FieldX").Name = "FieldY"

Set catTables = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top