rename table with VBA

  • Thread starter Thread starter mcnewsxp
  • Start date Start date
M

mcnewsxp

anybody have a VBA routine to rename tables after an a link to SQL that gets
rid of the "dbo_?"
tia.
 
Public Sub RenameAllTables(strToFind As String, strToReplace)

Dim dbs As Database
Dim tdf As TableDef

Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
Dim tdfNewName As String

tdfNewName = Replace(tdf.Name, strToFind, strToReplace)

If tdfNewName <> tdf.Name Then
DoCmd.Rename tdfNewName, acTable, tdf.Name
End If

Next

End Sub
 
Back
Top