Can I rename a column name from a table using Visual Basic?

G

Guest

Hi.

When I import files, usually they don't have the right columns name that I
have to use with como queries.

What I would like to do is, after import any file to access, rename the
columns name.

Can you help me, either, how can I have a cicle to see the table definitions
so that I can rename the columns table.

thanks for any help.
 
G

Guest

Thanks to Douglas J Steele, I found the answer after some search.
This works perfectly:

---------------------
Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef

Set dbCurr = CurrentDb()
Set tdfCurr = dbCurr.TableDefs("MyTableName")
tdfCurr.Fields("Field1").Name = "NewName1"
tdfCurr.Fields("Field2").Name = "NewName2"
tdfCurr.Fields("Field3").Name = "NewName3"
dbCurr.TableDefs.Refresh

Set tdfCurr = Nothing
Set dbCurr = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top