Referencing data in objects (tables, forms, queries, reports) is a basic skill in the Microsoft Access developer's toolkit, but what if you need to reference the objects themselves as part of a custom administrative interface (for example)?
Answer:
By referencing the [Name] field in the hidden Access system table "MSysObjects" and using the [Type] field as a filter criteria you can use Access objects such as tables, forms, queries, reports, and even modules as values in a queries, form controls, reports, etc. This can be especially useful when developing a full scale custom MS Access database application.
Object Type | Type ID |
Tables |
1
|
Forms |
-32768
|
Queries |
5
|
Reports |
-32764
|
Modules |
-32761
|
Below is a sample query for listing Access form objects.
SELECT MSysObjects.Name
FROM MSysObjects
WHERE (((Left$([Name],1))<>"~") AND ((MSysObjects.Type)=-32768))
ORDER BY MSysObjects.Name;
This can easily be modified for each object type by change the type criteria in the query.
A downloadable example, including queries for each object type and a demonstration of populating a list box with Access system objects, can be found on the AccessInsider Examples Page.
A downloadable example, including queries for each object type and a demonstration of populating a list box with Access system objects, can be found on the AccessInsider Examples Page.
0 comments:
Post a Comment