INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How To

Search query objects for specific field element by randysmid
Posted: 9 Feb 04

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

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close