Searching inside a Query

  • Thread starter Kishore Ramakrishnan
  • Start date
K

Kishore Ramakrishnan

Hi All,

I have a few MS Access 2003 MDB files and I want to search for a string in
the SQL query text of these MDBs. Is there a way to retrieve the text
(source) of a query?

Thanks,

Kishore.
 
M

Marshall Barton

Kishore said:
I have a few MS Access 2003 MDB files and I want to search for a string in
the SQL query text of these MDBs. Is there a way to retrieve the text
(source) of a query?


Here's some air code to get you started.

Dim strFile As String
Dim dbFile As DAO.Database
Dim qdf As DAO.QueryDef
strFile = "<full path to some file>"
Set dbFile = OpenDatabase(strFile)

For Each qdf In dbFile.QueryDefs
If qdf.SQL Like "*<the string>*" Then
Debug.Print strFile, qdf.Name, qdf.SQL
End If
Next qdf
Set dbFile = Nothing
 
K

Kishore Ramakrishnan

Thanks Marsh. I will try this.

Marshall Barton said:
Here's some air code to get you started.

Dim strFile As String
Dim dbFile As DAO.Database
Dim qdf As DAO.QueryDef
strFile = "<full path to some file>"
Set dbFile = OpenDatabase(strFile)

For Each qdf In dbFile.QueryDefs
If qdf.SQL Like "*<the string>*" Then
Debug.Print strFile, qdf.Name, qdf.SQL
End If
Next qdf
Set dbFile = Nothing
 
Top