How to Disable a Button & Move the Focus to a Specified ObjectLast reviewed: November 20, 1995Article ID: Q139874 |
The information in this article applies to:
SUMMARYWhen using a command button to set the focus to another object, you may sometimes want to disable the command button and move the focus to another object until another event occurs or a value is entered in a field. This article shows by example how to do it.
MORE INFORMATIONThe most obvious solution, doesn't work. You can't use the SetFocus method followed by "Enabled=.F." in the Click event of a command button. When the Click event of the command button is activated, the command button becomes disabled, but the focus is not moved to the specified control. The focus moves to the next object in the Tab Order instead of to the specified object. This occurs because the Default event processing occurs after user-defined code is run. When the default event procedure for the Click event is run, it discovers that the control is no longer enabled and defaults to setting the focus to the next object in the Tab order, so the user-specified SetFocus method is nullified. To move the focus to the object specified in the Click event of the command button, you need to use the NoDefault clause. This results in the focus being moved to the correct object.
Step-by-Step Example
REFERENCESFor additional information on the use of the NODEFAULT command, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q131095 TITLE : How to Control the Occurrence of a Default EventFor additional information on SetFocus behavior, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q130525 TITLE : PRB: SetFocus Doesn't Work When Called in the Valid Event |
Additional reference words: 3.00 VFoxWin got disable commandbutton
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |