How to Enable One Check Box While Disabling the Others

Last reviewed: April 30, 1996
Article ID: Q111918
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 2.5b
  • Microsoft FoxPro for Macintosh, version 2.5b

SUMMARY

It is often desirable to enable one check box while disabling the others on a screen. By enabling only one check box and disabling the others, the color of the disabled ones will change and become dimmed. This will emphasize that only one of these check boxes can be selected at any given time.

See the procedure below for a demonstration of how to accomplish this.

MORE INFORMATION

Below are the steps to create the check boxes:

  1. Open the Screen Builder and select the Check Box tool. (In FoxPro for MS-DOS, choose Check Box from the Screen menu.)

  2. Create three check boxes on the screen with the first one having the variable check1, the second one having the variable check2, and the third one having the variable check3.

  3. In the VALID clause of the first check box, type in this code:

          IF check1=1
    
             SHOW GET check2 DISABLED
             SHOW GET check3 DISABLED
          ELSE
             SHOW GET check2 ENABLED
             SHOW GET check3 ENABLED
          ENDIF
    
    

  4. In the VALID clause of the second check box, type in this code:

          IF check2=1
    
             SHOW GET check1 DISABLED
             SHOW GET check3 DISABLED
          ELSE
             SHOW GET check1 ENABLED
             SHOW GET check3 ENABLED
          ENDIF
    
    

  5. In the VALID clause of the third check box, type in this code:

          IF check3=1
    
             SHOW GET check1 DISABLED
             SHOW GET check2 DISABLED
          ELSE
             SHOW GET check1 ENABLED
             SHOW GET check2 ENABLED
          ENDIF
    
    
After generating the screen and running it, click one of the check boxes. When one box is selected, the others will be disabled. To enable all the check boxes, click the box that is selected (the one that has an "X" in it). This will clear the box and make all the check boxes enabled until another check box is selected.

The variables check1, check2, and check3 will always have a value of 0 or 1. Therefore, when the variable is evaluated, this is how the IF statement is used enable or disable the check boxes.


Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b
checkbox
KBCategory: kbprg
KBSubcategory: FxtoolSbuilder


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 30, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.