This is the reason: we have a huge Access 97 database with many GB's of
data (spread over like 20 .mdb files), and at least 15 users are
connected to it at any point in time. It is on a fairly fast computer,
but it took 3mins, 18 secs to run the following code on just 1889 queries.
On my own computer, I did a test, and I got results like yours.
However, even 15 seconds is a little slow... What if i want to redesign
the Access explorer (or whatever it is called), from which we may select
queries - and i want to include custom columns for custom properties of
query defs? And sorting? 15 seconds a very long time, and 3 minutes is
an unimaginably slow.
Public Sub FindQueries3(Optional ByVal Sql As String = "", Optional
PrintSql As Boolean = False, _
Optional Description As String = "", Optional CreatedAfter As Date =
#1/1/1900#, _
Optional CreatedBefore As Date = #1/1/1900#, Optional LastUpdatedAfter
As Date = #1/1/1900#)
Dim qry As QueryDef
Dim bln As Boolean
On Error Resume Next
Debug.Print
Debug.Print
Debug.Print Now
For Each qry In CurrentDb.QueryDefs
bln = False
If Sql <> "" Then bln = bln Or (InStr(qry.Sql, Sql) <> 0)
If Description <> "" Then bln = bln Or (InStr(1,
qry.Properties("Description"), Description, vbTextCompare) <> 0)
If CreatedAfter <> #1/1/1900# Then bln = bln Or (CreatedAfter <
qry.Properties("DateCreated"))
If CreatedBefore said:
qry.Properties("DateCreated"))
If LastUpdatedAfter <> #1/1/1900# Then bln = bln Or
(LastUpdatedAfter < qry.Properties("LastUpdated"))
If bln Then
'Debug.Print "Query Name:"
'Debug.Print qry.Name
If PrintSql Then
Debug.Print
Debug.Print "SQL:"
Debug.Print qry.Sql
'Debug.Print
Debug.Print "Query Description:"
Debug.Print qry.Properties("Description")
Debug.Print
Debug.Print
End If
End If
Next
Debug.Print Now
Debug.Print "Done"
End Sub