Rename Multiple Tables at once

D

DFruge

I have an Access 2007 database that has a lot of linked tables and I
want to 'batch' rename them. For example, they all start with "dbo_"
and I want to rename all of them to "PM_". How can I make that
happen? I've been searching and cannot find a solution. Any help
that anyone can provide is greatly appreciated.
 
D

Douglas J. Steele

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

Set dbCurr = CurrentDb()
For Each tdfCurr In dbCurr.TableDefs
If Left(tdfCurr.Name, 4) = "dbo_" Then
tdfCurr.Name = "PM_" & Mid(tdfCurr.Name, 5)
End if
Next tdfCurr

Set tdfCurr = Nothing
Set dbCurr = Nothing
 
S

Steve

Be aware ythat your database will no longer work after you do this. All your
queries, forms, reports and code are designed to work with the existing
table names.

Steve
(e-mail address removed)
 
J

John... Visio MVP

Are you sure?

John... Visio MVP

Steve said:
Be aware ythat your database will no longer work after you do this. All
your queries, forms, reports and code are designed to work with the
existing table names.

Steve
(e-mail address removed)
 

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