how to change a table column name on access with an alter query

hi

i have a table that the name is "table1" and there is a field with the name "field2" and i want to change it to the name "field1" how can i make it, something  like this:

ALTER TABLe table1
ALTER COLUMN field2 field1

thanks alot
bill201Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gplanaCommented:
Do you need to change it from SQL? Access has a "Design mode" to design a table manually, where you can edit the name of the columns and any other things.

As I know, the only way to rename a table column on Access by SQL is to drop the column and add the column (but if you do so, you will have to copy the data first to another table and load back after your DROP+ADD operation is complete).
0
Gustav BrockCIOCommented:
You can't. But you can use VBA:
 Dim  db  As  DAO.Database 
     Dim  tdd  As  DAO.TableDef 
     Set  db = CurrentDb() 
     Set  td = db.TableDefs(YourTableName) 
     td.Fields(CurrentFieldName).Name = NewFieldName 

Open in new window

Of course, the table has to be closed to allow this.

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bill201Author Commented:
thanks alot
0
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.