Where Used Tool to Find Queries That Reference a Query/Table

  • Thread starter Dennis W. Bulgrien
  • Start date
D

Dennis W. Bulgrien

Has anybody written a macro or VBA code that finds the first/next query or all
queries that reference (use in its FROM clause) a given query or table name?
 
J

Joe Fallon

Lots of companies sell such a tool:
FMS
Speed Ferret (Black Moshanon?)

There may be a free utility called Find Replace.
Try a Google search.
 
D

Dennis W. Bulgrien

Okay then. Here is one I just wrote that anybody is welcome to use.

' Desc: Searches all queries in current database for a requested text
Sub QueryWhereUsed()
Dim sText As String
Dim sQueries As String
Dim i As Integer
Dim qdf As QueryDef

sText = InputBox("SQL Text?")
For Each qdf In CurrentDb.QueryDefs
i = InStr(qdf.SQL, sText)
If i Then
MsgBox Left$(qdf.SQL, i - 1) & Space$(8) & sText & Space$(8) &
Mid$(qdf.SQL, i + Len(sText)), , qdf.Name
sQueries = sQueries & qdf.Name & vbCr
End If
Next qdf
MsgBox sQueries & vbCr & "End of search.", , "Query Where Used"
End Sub

"Dennis W. Bulgrien" <dbulgrien vcsd com> wrote in message
Has anybody written a macro or VBA code that finds the first/next query or all
queries that reference (use in its FROM clause) a given query or table name?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top