Article ID: 189923 - Last Review: May 13, 2003 - Revision: 3.0 PRB: No Validate Event When Activating CommandButtonThis article was previously published under Q189923 On This PageSYMPTOMS
On a form in Visual Basic, you have a CommandButton whose CausesValidation
property is True. Also, the CommandButton's Default or Cancel properties
are True. The Default and Cancel properties allow you to activate the
CommandButton by pressing the ENTER or ESC keys. When you activate the
CommandButton by pressing ENTER or ESC, the Validate event for the current
control does not occur and the Click event of the CommandButton fires. This
may cause undesirable results if you need the Validate event for the
current control to occur before the Click event of the CommandButton. If you activate the CommandButton using the mouse or the CommandButton's accelerator key, the Validate event for the current control occurs as expected. CAUSE
When you activate a "default" or "cancel" CommandButton by pressing the
ENTER or ESC keys, focus does not change to the CommandButton. Because
Focus remains in the current control, the Validate event for the current
control does not occur. In short, the CausesValidation property for a
Default or Cancel CommandButton is ignored when you activate the
CommandButton by pressing the ENTER or ESC keys.
RESOLUTION
To work around this limitation when using Default or Cancel CommandButtons,
you must add your validation code to the Click event of the CommandButton.
STATUS
This behavior is by design.
MORE INFORMATIONSteps to Reproduce Behavior
| Article Translations
|
Back to the top
