Article ID: 314431 - Last Review: May 12, 2003 - Revision: 2.0 PRB: Programmatically Changing Focus Does Not Cause ValidationThis article was previously published under Q314431 On This PageSYMPTOMS
Code that changes the value of a TextBox or of another control, and then moves the focus to another control where the CausesValidation property is True does not fire the Validate events of the changed control.
CAUSE
This behavior occurs because changing the focus with code does not trigger Validate event.
RESOLUTION
To resolve this behavior, call the ValidateControls method when you change values and focus by the use of code.
STATUSThis behavior is by design. MORE INFORMATION
By design, if you change the values of controls in code, you must explicitly call ValidateControls to run the Validate events. Validate does not run automatically in this scenario. Similarly, if you close the form after you edit a control without leaving that control, the Validate event does not fire because it does not lose focus. In this case, you can use the QueryUnload event of the Form to decide if ValidateControls should be called.
Steps to Reproduce the Behavior
REFERENCESFor additional information about Validate and CausesValidation, click the article numbers below
to view the articles in the Microsoft Knowledge Base:
197128
(http://support.microsoft.com/kb/197128/EN-US/
)
BUG: CausesValidation Property Does Not Trigger Validate Event
189923
(http://support.microsoft.com/kb/189923/EN-US/
)
PRB: No Validate Event When Activating CommandButton
| Article Translations
|

Back to the top
