CurrentProjectオブジェクトの使い方

Access 2000で追加されたCurrentProjectオブジェクトの使い方を紹介します。


使用例1

この例では、データベースのフルパス名、パス名、データベース名を取得します。

? CurrentProject.FullName
D:\Temp\Temp2.mdb

? CurrentProject.Name
Temp2.mdb

? CurrentProject.Path
D:\Temp        
        


使用例2

この例では、CurrentProjectのコレクションを利用してフォーム、レポート、マクロ、モジュール、データアクセスページなどのオブジェクト名を取得しています。

Dim obj As AccessObject
For Each obj In CurrentProject.AllDataAccessPages
      Debug.Print obj.Name
Next obj
For Each obj In CurrentProject.AllForms
      Debug.Print obj.Name
Next obj
For Each obj In CurrentProject.AllMacros
      Debug.Print obj.Name
Next obj
For Each obj In CurrentProject.AllModules
      Debug.Print obj.Name
Next obj
For Each obj In CurrentProject.AllReports
      Debug.Print obj.Name
Next obj