Next Obj
For Each Obj In CurrentProject.AllMacros
RecSet.AddNew
RecSet!ObjectName = Obj.Name
RecSet!ObjectType = "Macro"
RecSet!DateCreated = Obj.DateCreated
RecSet!DateModified = Obj.DateModified
RecSet.Update
Next Obj
For Each Obj In CurrentProject.AllModules
RecSet.AddNew
RecSet!ObjectName = Obj.Name
RecSet!ObjectType = "Module"
RecSet!DateCreated = Obj.DateCreated
RecSet!DateModified = Obj.DateModified
RecSet.Update
Next Obj
Set Dbs = Nothing
Set Obj = Nothing
Set RecSet = Nothing
End Sub
This code uses theDimstatement to set up objects and aRecordsetobject. The table
tblObjectInventory is cleared out using aDeletestatement.
The Dbs object is set to point to the application’s current data. This is used for queries and
tables. The code then iterates through each collection (AllTables, AllQueries, AllForms,
AllReports, AllMacros, and AllModules) and creates new records in the table
tblObjectInventory.
Run this code and then open the table tblObjectsInventory. You will see all the details of
the database objects, detailing when each object was created and last modified.
Chapter 32: Create an Objects Inventory 319