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
[email protected]
 
Top