Searching inside a Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
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
 

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

Back
Top