Queries listing

  • Thread starter Thread starter Michael Wong
  • Start date Start date
M

Michael Wong

Hi,

I am trying to display a list of all queries I have in a database with the
code below, and I got some named: ~sq_aFormName~sq_aControlName wich I
cannot see in the queries list.
What are they? How can I do to just display the normal one I can see in the
queries list?

Private Sub ListQueries()
Dim query As QueryDef
For Each query In CurrentDb().QueryDefs
Debug.Print query.Name
Next query
End Sub
 
The list of all objects with an Access Database is stored
in the System Table "MSysObjects".

To list all of the Queries, you could create a Query using
the following Criteria: -

SELECT MSysObjects.Name, MSysObjects.Type
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "~*") AND
((MSysObjects.Type)=5))
ORDER BY MSysObjects.Name;

HTH


Tony C.
-----Original Message-----
Hi,

I am trying to display a list of all queries I have in a database with the
code below, and I got some named:
~sq_aFormName~sq_aControlName wich I
 
Tony,

This is very helpful. But I still need to know, where did you get this info?

Thank you
 
Anytime you use SQL to set the RecordSource for a form or control, rather
than using an existing query (or table), Access creates a query under the
covers. ~sq_aFormName~sq_aControlName would be the SQL associated with
control aControlName on form aFormName.

As Tony points out, simply ignore any query that starts with ~ and you'll be
fine.
 
Thank you Douglas,

That clears up everything.

Douglas J. Steele said:
Anytime you use SQL to set the RecordSource for a form or control, rather
than using an existing query (or table), Access creates a query under the
covers. ~sq_aFormName~sq_aControlName would be the SQL associated with
control aControlName on form aFormName.

As Tony points out, simply ignore any query that starts with ~ and you'll be
fine.
 
Back
Top