You dont.
once you names queries/tables/macros, etc, renaming destroys the links.
NOW, Ive had to do what you need also. So to help in my edit....
i wrote this to help change all my queiries if I renamed a table, without breaking my queries.
!!!!!BACKUP YOUR DB BEFORE YOU RUN THIS!!!!!
The code below will find and replace a word in every query, with out the need to
find and edit every query in the database.
You can run this in the DBUG WINDOW. ( CTL-G )
usage:
ReplaceInSql "findTxt", "replaceWithTxt" 'updates ALL queries in db
IF YOU WANT TO REPLACE ONLY certain types of queries use these code letters in the command:
"A" 'append query
"U" 'update query
"S" 'select
"D" 'delete
"M" 'make
"N" 'UNION
"X" 'crosstab
usage:
ReplaceInSql "findTxt", "replaceWithTxt", "U" 'only update queries
ReplaceInSql "findTxt", "replaceWithTxt", "M" 'only MAKE TABLE queries
Code:
Public Sub ReplaceInSql(pvFind, ByVal pvReplaceWith, Optional ByVal pvQType)
Dim db As Database
Dim qdf As QueryDef
Dim vFind, vQnum
Dim sSql As String
Const kQS = 0
Const kQD = 32
Const kQU = 48
Const kQA = 64
Const kQM = 80
Const kQN = 128
Const kQX = 16
If IsMissing(pvQType) Then pvQType = ""
Select Case pvQType
Case "A" 'append
vQnum = kQA
Case "S" 'select
vQnum = kQS
Case "D" 'delete
vQnum = kQD
Case "U" 'update
vQnum = kQU
Case "M" 'make
vQnum = kQM
Case "N" 'UNION
vQnum = kQN
Case "X" 'crosstab
vQnum = kQX
Case Else
vQnum = ""
End Select
vFind = pvFind '"tRptDefectsBlocked"
Set db = CurrentDb
Debug.Print "--Start qry replace on:" & vFind
For Each qdf In db.QueryDefs
sSql = qdf.SQL
If Left(qdf.Name, 1) <> "z" And Left(qdf.Name, 1) <> "~" Then
If InStr(sSql, vFind) > 0 Then
If pvQType = "" Then 'replace ALL queries
GoSub REPLACEIT
Else
If qdf.Type = vQnum Then
GoSub REPLACEIT
End If
End If
End If
End If
Next
Debug.Print "--End qry replace"
Set qdf = Nothing
Set db = Nothing
Exit Sub
REPLACEIT:
Replace2 sSql, pvFind, pvReplaceWith
qdf.SQL = sSql
Debug.Print getQryTypeNam(qdf.Type); " "; qdf.Name
qdf.Close
Return
End Sub