Thursday, November 12, 2009

Renaming a Bunch of Tables

I am working on a conversion database that requires linking to lots of tables in lots of databases with exactly the same tables. I then need to rename the linked tables to remove the Suffix of 1 (that appears on all linked tables that are the same) and give the new linked tables a new prefix . Here is the code to do that


Private Sub cboLive_Click()

Dim tbl As DAO.TableDef

For Each tbl In CurrentDb.TableDefs
If Right$(tbl.Name, 1) = "1" Then
tbl.Name = "MyPrefix_" & Left$(tbl.Name, Len(tbl.Name) - 1)
End If
Next

End Sub


Here is a similar post for removing DBO prefix for SQL linking.

No comments: