Hello,
Our databases often have a huge number of queries, and it becomes difficult searching them for a specific field element. Here is code that you can place in a module, and it will write to a text file all the occurrences of a particular field. Be sure to change the name of the output file, as well as the field name to be searched.
Public Sub SearchQueryObjects()
Dim db As Database
Dim qry As QueryDef
Dim fld As Field
Set db = CurrentDb
Dim strFileName As String
strFileName = "c:\SearchQueries.txt"
Open strFileName For Output As #1
'Open "c:\SearchQueries.txt" For Output As #1
For Each qry In db.QueryDefs
For Each fld In qry.Fields
If fld.NAME = "fldChangeNameHere" Then ' <<<---------- search field
Print #1, qry.NAME & " ----> " & fld.NAME & ", "; fld.SourceTable
End If
Next fld
Next qry
Close #1
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.