A report stops in the ACCDE with error 459 "Object or class does not support the set of events"
Environment
Microsoft 365 Access 16.0.20527, 32 bit. A report that holds an ActiveX control and has a VBA module of its own (Has Module = Yes), compiled into an ACCDE. The control does not have to be a WKL control: the same failure occurs with Windows Media Player and the Microsoft Forms 2.0 command button. Forms are not affected.
The report prints in the ACCDB. In the ACCDE (and in the Access Runtime) it stops as soon as it opens, with error 2473 naming its first event (“The expression On Format you entered as the event property setting produced the following error: Object or class does not support the set of events”), or with VBA error 459 of the same text.
Cause
A defect of Access. The ACCDE holds a wrongly compiled report module when the module came into being in the same design session in which the report's record source was set or changed, while the report holds an ActiveX control. The error comes from Access before any procedure of the report runs; the control itself is not called.
How Access behaves, each sequence in a database of its own:
| Sequence in design view | ACCDE |
|---|---|
| Record source and module in one design session (save, close) | fails |
| Record source in one session, module in a later one | prints |
The whole report created by LoadFromText (the text has record source, ActiveX control and module) | fails |
| The same text without its module, the module added in a later session | fails |
| The same text without its record source, the record source set in a later session | fails |
A failing report saved again, a comment added to its module, or SaveAsText and LoadFromText again | still fails |
| A failing report: Has Module set to No in one session, the module created in a later one | prints |
Because LoadFromText creates the whole report at once, every report that a build from text sources creates with an
ActiveX control and a module fails in the ACCDE unless the build repairs it.
Resolution
Built with the build tool: the build tool of the WKL Forms Object Library (tools/build/Build-AccessApp.ps1) repairs such
reports itself: after loading a report with an ActiveX control and a module it removes the module in one design session
and creates it again, with the same code and the same event properties, in a second one. Build again and make the ACCDE
again; nothing changes in the sources.
Without a report module: a report whose events are expressions calling public functions of a standard module (for
example the event property On Format of the detail section =FormatStelle()) has no module of its own and is not
affected. How to: Print gauges and charts in a report shows this
form; it also applies to reports made in Access by hand.