Dec 18, 2003 #1 mikeyb540 Programmer Jul 7, 2003 173 US Hello, Is there a way I can rename Tables in the MSysObjects table? Txs in advance.
Dec 18, 2003 1 #2 vbajock Programmer Jun 8, 2001 1,921 US Sounds risky. Why would you want to do that? Upvote 0 Downvote
Dec 18, 2003 Thread starter #3 mikeyb540 Programmer Jul 7, 2003 173 US I have 230 linked SQL server tables. When linked i get the dbo_table1 and the code refrences to table1. Any other way I can link the tables without the dbo? Txs Upvote 0 Downvote
I have 230 linked SQL server tables. When linked i get the dbo_table1 and the code refrences to table1. Any other way I can link the tables without the dbo? Txs
Dec 18, 2003 #4 vbajock Programmer Jun 8, 2001 1,921 US Do it on a BACKUP COPY. Set a reference to the DAO 3.6 object library Public Sub RenameAllTables(strToFind As String, strToReplace) On Error GoTo ErrHandler Dim dbs As Database Dim tdf As TableDef Set dbs = CurrentDb For Each tdf In dbs.TableDefs Dim tdfNewName As String if mid$(tdf.name,1,4)="dbo_" tdfNewName = mid$(tdf.Name,4,255) DoCmd.Rename tdfNewName, acTable, tdf.Name endif NextTdf: Next Cleanexit: Exit Sub ErrHandler: MsgBox Err.Number & " - " & Err.description, vbOKOnly Resume NextTdf GoTo Cleanexit End Sub Upvote 0 Downvote
Do it on a BACKUP COPY. Set a reference to the DAO 3.6 object library Public Sub RenameAllTables(strToFind As String, strToReplace) On Error GoTo ErrHandler Dim dbs As Database Dim tdf As TableDef Set dbs = CurrentDb For Each tdf In dbs.TableDefs Dim tdfNewName As String if mid$(tdf.name,1,4)="dbo_" tdfNewName = mid$(tdf.Name,4,255) DoCmd.Rename tdfNewName, acTable, tdf.Name endif NextTdf: Next Cleanexit: Exit Sub ErrHandler: MsgBox Err.Number & " - " & Err.description, vbOKOnly Resume NextTdf GoTo Cleanexit End Sub
Dec 18, 2003 #5 vbajock Programmer Jun 8, 2001 1,921 US Just ignore (strToFind As String, strToReplace), it doesn't belong in the snippet I gave you Upvote 0 Downvote
Dec 18, 2003 Thread starter #6 mikeyb540 Programmer Jul 7, 2003 173 US You the man it worked But it renamed them as _table1 ...etc hmmm... how do I remove the _? Txs Upvote 0 Downvote
Dec 18, 2003 Thread starter #7 mikeyb540 Programmer Jul 7, 2003 173 US I tried If Mid$(tdf.Name, 1, 1) = "_" Then tdfNewName = Mid$(tdf.Name, 1, 255) doesnt do anything Upvote 0 Downvote
I tried If Mid$(tdf.Name, 1, 1) = "_" Then tdfNewName = Mid$(tdf.Name, 1, 255) doesnt do anything
Dec 18, 2003 1 #8 Golom Programmer Sep 1, 2003 5,595 CA That's 'cause you need tdfNewName = Mid$(tdf.Name, 2, 255) Upvote 0 Downvote
Dec 18, 2003 Thread starter #9 mikeyb540 Programmer Jul 7, 2003 173 US That did it... Txs Upvote 0 Downvote
Dec 19, 2003 #10 vbajock Programmer Jun 8, 2001 1,921 US Sorry about that! You might also want wrap it in a trim function tdfNewName = Trim$(Mid$(tdf.Name, 2, 255)) so you don't get any unwanted spaces Upvote 0 Downvote
Sorry about that! You might also want wrap it in a trim function tdfNewName = Trim$(Mid$(tdf.Name, 2, 255)) so you don't get any unwanted spaces
Dec 19, 2003 Thread starter #11 mikeyb540 Programmer Jul 7, 2003 173 US Vbajock, Txs for all you help. Happy Holidays Upvote 0 Downvote