changing a table name

D

dshemesh

Hello,
I have an access project in which I want to change some tables names
dynamically using visual basic code. is there any way doing this?
thank you
 
S

Scott McDaniel

Yes ... but if you change a table's name, any code relying on that table
will fail.

Assuming you have a reference to DAO set:

Dim tdf As DAO.TAbledef
Dim dbs As DAO.DAtabase

Set dbs = Currentdb
Set tdf = dbs.Tabledefs("YourTableName")
tdf.Name = "NewName"

Set dbs = Nothing
Set tdf = Nothing
 
D

dshemesh

great!! thanks!
--
dshemesh


Scott McDaniel said:
Yes ... but if you change a table's name, any code relying on that table
will fail.

Assuming you have a reference to DAO set:

Dim tdf As DAO.TAbledef
Dim dbs As DAO.DAtabase

Set dbs = Currentdb
Set tdf = dbs.Tabledefs("YourTableName")
tdf.Name = "NewName"

Set dbs = Nothing
Set tdf = 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