'-------------------------------------------------------------------------------
' Procedure : TruncateDBO
' DateTime : 3/13/2008 06:38
' Author : Donald R. Cossitt
' :
' Purpose : MS has the completely absurd notion that it is somehow
' : important to append 'DBO_' and or other database owner as a
' : prefix to linked tables. This routine truncates 'DBO_' from
' : the tables in the tabledefs collection having that
' : particular malady. However, will truncate any string
' : indicated by the user.
'-------------------------------------------------------------------------------
'
Public Sub TruncateDBO()
Dim tdfTable As DAO.TableDef
Dim i As Integer
Dim szDBOwner As String
szDBOwner = InputBox("Enter prefix to truncate. [case sensitive]", _
"TRUNCATE DB OWNER", "dbo_")
For Each tdfTable In CurrentDb.TableDefs
If Left(tdfTable.Name, Len(szDBOwner)) = szDBOwner Then
i = i + 1
tdfTable.Name = Right(tdfTable.Name, _
Len(tdfTable.Name) - Len(szDBOwner))
End If
Next tdfTable
MsgBox "Truncated : " & i & " table names", vbInformation, "'DBO_' GONE"
End Sub