Accessでオブジェクト一覧を取得する方法は主に4通りあります。
- TableDefs、QueryDefsを使ったオブジェクト一覧の取得
- MSysObjectsを使ったオブジェクト一覧の取得
- CurrentData、CurrentProjectを使ったオブジェクト一覧の取得
- Containerを使ったオブジェクト一覧の取得
- Application.Forms等を使ったオブジェクト一覧の取得
取得方法により、得られる内容(型)も変わりますので、目的に合わせて使用したいものです。
下記は、各オブジェクトが、どの方法で取得できるかを表したものです。
(○:取得可能 ×:取得不可 ○の下は使用するプロパティ名)
| 方法 | 取得型 | テーブル | クエリー | フォーム | レポート | マクロ | モジュール |
|---|---|---|---|---|---|---|---|
| ①TableDefs | DAO.TableDef | ○ | × | × | × | × | × |
| ①QueryDefs | DAO.QueryDef | × | ○ | × | × | × | × |
| ②MSysObjects | String | ○ | ○ | ○ | ○ | ○ | ○ |
| ③CurrentData.All~ | AccessObject | ○ AllTables | ○ All Queries | × | × | × | × |
| ③CurrentProject.All~ | AccessObject | × | × | ○ AllForms | ○ AllReports | ○ AllMacros | ○ AllModules |
| ④Containers | DAO.Document | △クエリーと区別なし | △クエリーと区別なし | ○ | ○ | ○ | ○ |
目次
参考
- TableDef
- QueryDef
- AccessObject
- DAO.Document
コメント