How to list all queries only of a database in a combobox.

X

xpengi

hi guys,

i got idea from other post to list all tables & queries of a databas
in a combobox with

"SELECT [Name] FROM MSysObjects WHERE [Type] = -32768",

is there way to list all queries only?

many thanks
 
A

Allen Browne

Type -32768 will give you the forms. Try type 5.

Hint: you could find this out for yourself if you change the WHERE clause to
the name of a query, and see what Type it is.
 
X

xpengi

if change "-32768" into "5" in query "SELECT [Name] FROM MSysObject
WHERE [Type] = -32768",
it appears sth like " ~sq_cfrmCountry_O~sq_cOLEUnbound0" in the combo
list.

you said, "Hint: you could find this out for yourself if you change th
WHERE clause to
the name of a query, and see what Type it is."

is it mean, "SELECT [Name] FROM MSysObjects query0"? it does not work.

i have existing query0, query1, query2 ... how to do it?

forgive my wooden head....&& THANKS
 
A

Allen Browne

You want the names where the Type is 5 and the name does not start with ~.

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

xpengi

it works, really thanks, Allen.

by the ways, in the same circumstance, what is the type number if lis
all tables only?

"SELECT [Name] FROM MSysObjects WHERE [Type] = ??????"
 
A

Allen Browne

Types in MSysObjects
================
Tables: 1
Queries: 5
Forms: -32768
Reports: -32764
Modules: -32761
Linked tables: 6
ODBC lined tabes: 4
 
Top