Code to Go thru DB and search queries to see if table is referenced...

  • Thread starter Andre Laplume via AccessMonster.com
  • Start date
A

Andre Laplume via AccessMonster.com

A table has significantly changed and now I must look thru numerous dbs at
each query and identify if that query links in the changed table. Does
anyone have any code that I might run that would report each query name that
links the particular table?

--
OOPs a typo...the statement that DOES NOT work is:

AdjAmt: Sum(IIf([TYPE]=2 And Left(Date(),2)="07",[Amt]*[Percent],IIf([TYPE]=1,
[Amt]*[Percent],0)))


Message posted via AccessMonster.com
 
G

Guest

Sub GetQueryNames()
Dim lngQcount As Long
'Change "actual_res_export" to the table name you want to look for.
Dim lngX As Long
Dim objQdefs As QueryDefs

Set objQdefs = CurrentDb.QueryDefs
lngQcount = objQdefs.Count - 1
For lngX = 0 To lngQcount
If InStr(objQdefs(lngX).SQL, "actual_res_export") <> 0 Then
Debug.Print objQdefs(lngX).Name
End If
Next lngX
End Sub


Andre Laplume via AccessMonster.com said:
A table has significantly changed and now I must look thru numerous dbs at
each query and identify if that query links in the changed table. Does
anyone have any code that I might run that would report each query name that
links the particular table?

--
OOPs a typo...the statement that DOES NOT work is:

AdjAmt: Sum(IIf([TYPE]=2 And Left(Date(),2)="07",[Amt]*[Percent],IIf([TYPE]=1,
[Amt]*[Percent],0)))


Message posted via AccessMonster.com
 
A

Andre Laplume via AccessMonster.com

I will try this...


T H A N K S !!!!!!!!!!!!!!!!!!!!!!!!!!!

Sub GetQueryNames()
Dim lngQcount As Long
'Change "actual_res_export" to the table name you want to look for.
Dim lngX As Long
Dim objQdefs As QueryDefs

Set objQdefs = CurrentDb.QueryDefs
lngQcount = objQdefs.Count - 1
For lngX = 0 To lngQcount
If InStr(objQdefs(lngX).SQL, "actual_res_export") <> 0 Then
Debug.Print objQdefs(lngX).Name
End If
Next lngX
End Sub
A table has significantly changed and now I must look thru numerous dbs at
each query and identify if that query links in the changed table. Does
anyone have any code that I might run that would report each query name that
links the particular table?
[Amt]*[Percent],0)))

--
OOPs a typo...the statement that DOES NOT work is:

AdjAmt: Sum(IIf([TYPE]=2 And Left(Date(),2)="07",[Amt]*[Percent],IIf([TYPE]=1,
[Amt]*[Percent],0)))
 

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