Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search query objects for specific field element

How To

Search query objects for specific field element

by  randysmid  Posted    (Edited  )
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


HTH, Randy Smith, MCP
California Teachers Assn
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top