Rename Multiple Tables at once

  • Thread starter Thread starter DFruge
  • Start date Start date
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.
 
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
 
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)
 
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)
 
Back
Top