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

Renaming fields with Alter Table Problem!!??

Status
Not open for further replies.

emumaster

Programmer
Aug 30, 2001
31
US
I have searched and tried everything in the forums and can't seem to get this code to work.

ALTER TABLE mytablename RENAME COLUMN oldfieldname TO newfieldname

It kicks an error when I try to run this query, stopping at the RENAME every time.

I am using Access 2002, no sql server.
Any suggestions??
 
How about adding a new column with the name you want, moving the data from the old column into the new, and then deleting the old column? Kind of tedious but the only way I've found for this to work. Kelly
 
Try this:
Dim db As Database
Set db = CurrentDb
' Rename the field
db.TableDefs("[" & TblName & "]").Fields("CurrentFieldName").Name = NewFieldName


Tom
 
Thanks for the fix! I appreciate how small the code is too!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top