Color scheme: Riviera
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library troubleshooting » An event procedure is never called

An event procedure is never called

A procedure such as Grid1_RowClick or btnSave_Click exists in the form module, but nothing happens when the user acts on the control - no breakpoint is reached, no message box appears.

Environment

Every WKL control and object, every release, Microsoft 365 Access (full and runtime) and Excel and Word UserForms.

Cause

One of these, most frequent first:

  • The form module does not compile. A module with a compile error anywhere receives no event at all, and Access reports it nowhere until the module is compiled: DoCmd.OpenForm called through Automation returns without opening the form, RunCommand acCmdCompileAndSaveAllModules raises no error. A frequent cause is a hand-typed declaration with a different number of parameters than the event has, or an enumeration type (WklUpdateAction, for example) while the reference to the WKL Forms Object Library is missing.
  • The form has no module. Has Module = No: Access passes no event of any control to the form. An empty module is enough.
  • The action came from code. Most events report what the user does. The same change made in code - SelectedKey = 5, Value = True, MoveNode, Requery - raises no event, like AfterUpdate of an Access text box set by code. Exceptions are named on their member: AfterTabChange of WklDockLayout (reason wtcCode), FilterChipRemoved (ByUser = False) and CommandStateChange also follow changes made by code.
  • A format event is switched off. NodeFormat, RowFormat and CellFormat occur only with FormatEvents = True (why).
  • The name does not match. The procedure must be named <control name>_<event>, with the control's current name; after renaming the control, the old procedure no longer belongs to it.
  • WithEvents inside a procedure, or the object is gone. For WklToast and WklLinkManager, the WithEvents variable must be declared at the top of a class or form module, and the object must still be held there (Set mToast = New WklToast) when the event occurs.
  • Another event procedure of the same control is still running. VBA delivers no event of an object while a procedure for an event of the same object runs. The record commands of WklGrid (DeleteSelected, NewRecord, and so on) called inside one of its own event procedures therefore run only after that procedure has ended, so their events arrive; other events raised meanwhile are lost.

Resolution

  1. In the VBA editor, choose Debug › Compile <project> and fix every error it shows; then check in the Immediate window that ? Application.IsCompiled returns True.
  2. Set Has Module of the form to Yes.
  3. Create the procedure through the object and procedure lists of the code window (or the designer Events page of the tree and grid controls), so that its name and declaration are right (how-to).
  4. For format events, set FormatEvents = True; for objects, move the WithEvents declaration to module level.
  5. To run code after an action you trigger yourself, call your procedure directly after the statement that triggers the action.
en/wiki/msaccess/comctl/troubleshooting/event-procedure-never-called.txt · Last modified: by Wolfgang van der Stille