Queries listing

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
 
T

Tony C

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
 
M

Michael Wong

Tony,

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

Thank you
 
D

Douglas J. Steele

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

Michael Wong

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.
 

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

Top