mwolfe02
mwolfe02

Reputation: 24237

Event raised when Access object saved?

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.

Upvotes: 0

Views: 83

Answers (1)

ThunderFrame
ThunderFrame

Reputation: 9471

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.

Upvotes: 0

Related Questions