rename table with VBA

M

mcnewsxp

anybody have a VBA routine to rename tables after an a link to SQL that gets
rid of the "dbo_?"
tia.
 
M

mcnewsxp

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
 

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