R
Rob Parker
I'm attempting to get a list of all queries in my database which have
parameters, via the following:
Dim qry As DAO.QueryDef
For Each qry In CurrentDb.QueryDefs
If qry.Parameters.Count > 0 Then
Debug.Print qry.Name
End If
Next qry
This fails, with RTE 3078 (MS Jet database engine cannot find query
'qryOrders_Arisings')
If I omit the inner If statement, and run the following, I get (as
expected) a list of all the queries:
For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next qry
This list does not include qryOrders_Arisings (which was previously in
the database, but was deleted ages ago).
If I change the code to:
For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name; qry.Parameters.Count
Next qry
I again get RTE 3078.
I've done a compact/repair; I've included
CurrentDb.QueryDefs.Refresh
at the top of my code; I've tried
CurrentDb.QueryDefs.Delete("qryOrders_Arisings")
which gives RTE 3265 (Item not found in this collection) - not
unsurprisingly.
What's going on here, and how can I fix it?
TIA,
Rob
parameters, via the following:
Dim qry As DAO.QueryDef
For Each qry In CurrentDb.QueryDefs
If qry.Parameters.Count > 0 Then
Debug.Print qry.Name
End If
Next qry
This fails, with RTE 3078 (MS Jet database engine cannot find query
'qryOrders_Arisings')
If I omit the inner If statement, and run the following, I get (as
expected) a list of all the queries:
For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name
Next qry
This list does not include qryOrders_Arisings (which was previously in
the database, but was deleted ages ago).
If I change the code to:
For Each qry In CurrentDb.QueryDefs
Debug.Print qry.Name; qry.Parameters.Count
Next qry
I again get RTE 3078.
I've done a compact/repair; I've included
CurrentDb.QueryDefs.Refresh
at the top of my code; I've tried
CurrentDb.QueryDefs.Delete("qryOrders_Arisings")
which gives RTE 3265 (Item not found in this collection) - not
unsurprisingly.
What's going on here, and how can I fix it?
TIA,
Rob