[转载]Return database object names
本文作者: Dev Ashish文章出处: super@hei
(Q) How can I retrieve names of database objects (queries /forms/ table/ reports/ modules/ macros) using a query?
(A) The Access system table MsysObjects table contains a list of all database objects. Although undocumented, you can query this table to retrieve the names you want.
Note: Use any Access system table with extreme caution. Unintentional or intentional modifications of any kind in these tables might result in an unusable database.
'Code Courtesy of
'Dev Ashish
'******************** Code Start ************************
[code]Use the following SQL statements as Rowsource for the control depending on which object you want.
Queries:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)=5 ORDER BY MSysObjects.Name;
Forms:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)=-32768 ORDER BY MSysObjects.Name;
Tables:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(Left$([Name],4) <> "Msys") AND (MSysObjects.Type)=1 ORDER BY MSysObjects.Name;
Reports:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)= -32764 ORDER BY MSysObjects.Name;
Modules:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)= -32761 ORDER BY MSysObjects.Name;
Macros:
SELECT MSysObjects.Name FROM MsysObjects WHERE (Left$([Name],1)<>"~") AND
(MSysObjects.Type)= -32766 ORDER BY MSysObjects.Name;[/code]
'******************** Code End ************************
页:
[1]