isladogs
MVP / VIP
- Local time
- Today, 11:11
- Joined
- Jan 14, 2017
- Messages
- 18,816
As previously stated
... many people turn it off when not actually currently needed.
... many people turn it off when not actually currently needed.
For something like this, I would use Rick Fisher's Find&Replace or TotalSearch from V-Tools. With these you can perform such a renaming operation in one go, comprehensively and in a controlled manner.However, I regularly reuse objects in new databases & that's when I will often rename tables/queries etc
Such one-armed giant does not really offer me any benefit.Things that name AutoCorrect does not correct
Name AutoCorrect does not correct the following:
- Changes to form, report, or control names are not tracked.
- Table, query, or field names in macros or in code are not corrected.
I didn't say I didn't use it. I explained why it is dangerous if you don't know how it works. If you know how it works, you turn it on and off and that avoids accidents that happen when you rename things and later find everything is now using the "old" version of the query/table and not the new version.Several years later, I went back to it & have used it with ZERO issues for about 15 years.
Another great solution to get to know the database application in front of you:
http://www.accessdependencychecker.com/ from Thomas Koester
However, I regularly reuse objects in new databases & that's when I will often rename tables/queries etc
SELECT Table1.ID, Table1.DummyTest, Table1.NumberText, Table2.TextField
FROM Table1 INNER JOIN Table2
ON Table1.ID = Table2.ID
- versus-
SELECT T1.ID, T1.DummyTest, T1.NumberText, T2.TextField
FROM Table1 AS T1 INNER JOIN Table2 AS T2
ON T1.ID = T2.ID
Using aliases certainly makes handling any renamed tables simpler / faster. Nevertheless, NAC works perfectly with aliased queriesIf it is the predominantly applied own style to work with table aliases,
As NAC only handles the outermost part of nested queries, it isn't useful (and probably unhelpful) to use it where you have a lot of subqueries.In deviation from the recommendation to avoid subqueries as best as possible, my queries often have only tables as data sources to be loaded.
!!!???The vast majority of queries are not inimitable highlights of developmental excellence with the need to copy this 1:1 and then adapt it in any processes.
ub PropagateNACObjectChanges()
Dim obj As Object
Dim strName As String
Dim qdf As DAO.QueryDef
Dim tdf As DAO.TableDef
Dim db As DAO.Database
Dim sngStart As Single, sngEnd As Single
On Error GoTo Err_Handler
DoEvents
Set db = CurrentDb
Application.Echo False
sngStart = Timer
For Each tdf In db.TableDefs
strName = tdf.Name
'exclude system tables and deleted tables (~TMPCLP*)
If Left(strName, 4) <> "MSys" And Left(strName, 2) <> "f_" And Left(strName, 7) <> "~TMPCLP" Then
DoCmd.OpenTable strName, acViewDesign
DoCmd.Close acTable, strName, acSaveYes
End If
Next tdf
For Each qdf In db.QueryDefs
strName = qdf.Name
'exclude deleted queries (~TMPCLP"), temp queries (~") used as record / row sources in forms & reports
'exclude queries that won't run e.g. ambiguous joins("#*)
If Left(strName, 1) <> "~" And Left(strName, 1) <> "#" Then
DoCmd.OpenQuery strName, acViewDesign
DoCmd.Close acQuery, strName, acSaveYes
End If
Next qdf
For Each obj In Application.CurrentProject.AllForms
strName = obj.Name
'exclude deleted forms (~TMPCLP*)
If Left(strName, 7) <> "~TMPCLP" Then
DoCmd.OpenForm strName, acDesign, , , , acHidden
DoCmd.Close acForm, strName, acSaveYes
End If
Next obj
For Each obj In Application.CurrentProject.AllReports
strName = obj.Name
'exclude deleted reports (~TMPCLP*)
If Left(strName, 7) <> "~TMPCLP" Then
DoCmd.OpenReport strName, acDesign, , , , acHidden
DoCmd.Close acReport, strName, acSaveYes
End If
Next obj
sngEnd = Timer
Application.Echo True
MsgBox "NAC Propagation Completed" & vbCrLf & vbCrLf & _
"Time taken = " & Round(sngEnd - sngStart, 3) & " s", vbInformation, "All done!"
Exit_Handler:
Exit Sub
Err_Handler:
' If Err = 7874 Then Resume Next
If Err = 3296 Then Resume Next 'JOIN expression not supported in query with ambiguous joins
Debug.Print "Error " & Err & " " & Err.Description & " in object " & strName
Resume Exit_Handler
End Sub