Search code examples
vbams-accessdatemodified

How to compare MS-Access created and last modified dates of tables, queries, forms, etc.?


I like to create a list when tables, queries, forms etc. were created and updated in an Access 2010 database.

In theory this is possible with a little VBA code but unfortunately this code shows the wrong information. I tested it myself and it is confirmed by Microsoft here: https://support.microsoft.com/en-us/kb/299554

Access shows the correct modified date on the Navigation Panel but it seems to be impossible to access this information via VBA or in any table. Some time ago I searched for this on the internet and a couple of people confirmed the problem but nobody had an answer.

Now my question: Does anybody know how to export the correct modified date information from Access (shown in the Navigation Panel)?

If this is impossible (my current research suggest this) does anyone know a reliable way to compare one database file to another and show all the differences in tables, queries, forms, etc.?

This is all about the design of the Access objects and not about any data stored in the tables.


Solution

  • That linked article describes why the LastUpdated property doesn't give you what you want for database objects such as forms and reports. Unfortunately it doesn't tell you that you can use DateModified from the appropriate CurrentProject collection for those.

    For example, consider this screen capture of a form in the Navigation pane:

    Navigation pane showing a form

    When referencing that form in the Documents collection, LastUpdated and DateCreated both return the same value:

    ? CurrentDb.Containers("Forms").Documents("Form1").DateCreated
    8/20/2012 10:51:07 PM 
    ? CurrentDb.Containers("Forms").Documents("Form1").LastUpdated
    8/20/2012 10:51:07 PM
    

    However DateModified for that same form in the CurrentProject.AllForms collection gives you the value which is displayed in the Navigation pane:

    ? CurrentProject.AllForms("Form1").DateModified
    7/1/2015 6:47:40 AM 
    

    Note you can also get DateCreated via AllForms:

    ? CurrentProject.AllForms("Form1").DateCreated
    8/20/2012 10:51:07 PM 
    

    Other CurrentProject collections include: AllMacros; AllModules; and AllReports. Beware that modules are saved together so DateModified shows you the time the project was last saved. That means each module will show that same time, the same as displayed in the Navigation pane.