0

This question references some events raised by the VBIDE. I'm looking for an event I can hook that is raised whenever an Access object is saved (form, querydef, module, class module, etc.).

If such an event is unavailable, I'm looking for workarounds. A project-wide save event or a code module change event would be acceptable alternatives. Perhaps there is some creative way to be notified when one of the "msys" system tables is updated and, ideally, which row.

Worst-case scenario, it looks like I can iterate through the CurrentDb.QueryDefs .LastUpdated or CurrentProject.AllForms/.AllModules/.AllReports .DateModified property and just poll it on some interval, but I would like to avoid that if possible.

Community
  • 1
  • 1
mwolfe02
  • 23,787
  • 9
  • 91
  • 161
  • No, there is no global event. AFAIK, the DateModified property has not been correct since Access 97. What is the issue that you are trying to solve? – AVG Sep 06 '16 at 00:47
  • I'm writing a .NET add-in to automate version control integration. I want to do a SaveAsText as needed when individual Access objects are saved. – mwolfe02 Sep 06 '16 at 03:32
  • DateModified changes every time when you compacting database, it won't help. Here you can find some ideas for workaround: http://www.sql.ru/forum/1203855/kak-programmno-otsledit-fakt-otkrytiya-formy-v-rezhime-konstruktora Sorry, It's in Russian. There you can find VBA code for monitoring of objects open/close and idea to save text of objects and compare saved text. I would recommend to add .NET tags to the question – Sergey S. Sep 06 '16 at 03:38
  • A simple Google search brings up quite a few results. Here is the top one http://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-development – AVG Sep 06 '16 at 10:17
  • @AVG I am already using a heavily modified version of that script. The problem is it takes a few minutes to export all the objects in a large database. The purpose of the add-in is to do the export continuously as individual objects are changed. – mwolfe02 Sep 06 '16 at 10:46
  • Nice idea, but I think you are going to hit a wall. Good luck! – AVG Sep 06 '16 at 15:42

1 Answers1

0

There aren't any events that you can catch, but there is probably a better solution than polling the database objects.

The Database Window (that contains all of the tables, queries and other objects) will receive Windows messages when certain things happen in the User Interface. A quick look with Spy++ shows that the Database Window appears to receive a WM_ENABLE message when an object is saved. If you can trap that message using Win32, you might have the beginnings of a reliable "event".

Note that VBA UserForms can be used in Access Projects, but they don't appear in the Database Window, so that might be a problem.

Also, anything that programmatically changes/adds/deletes database objects might not trigger an automatic Database Window refresh or message.

ThunderFrame
  • 9,352
  • 2
  • 29
  • 60