PRB: Variable Defined in WHEN Not Found in VALID

ID: Q121344

The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5x, 2.6
  • Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6

SYMPTOMS

The error message "Variable 'myvar' not found" occurs in the VALID code snippet when the variable was initialized in the WHEN code snippet.

RESOLUTION

To solve this problem, do one of the following:

  • Define the variable in the Setup code snippet of the screen with the PUBLIC or REGIONAL command. For example:

          PUBLIC myvar
    

    -or-

  • Assign the variable an initial value of "" (for character variables) or 0 (for numeric variables).

MORE INFORMATION

Steps to Reproduce Behavior

1. Open CUSTOMER.DBF by issuing the following command in the Command

   window:

     USE <FoxPro_directory>\tutorial\customer.dbf

2. Create a quick screen.

3. Edit the WHEN code snippet of the CONTACT field. Select Procedure and

   enter the following commands:

      m.myvar = customer.contact
      WAIT WINDOW customer.contact
      WAIT WINDOW m.myvar

4. Edit the VALID code snippet of the CONTACT field. Select Procedure and
   enter the following command:

      WAIT WINDOW customer.contact
      WAIT WINDOW m.myvar

5. Save and generate the screen. Run the screen by issuing the following
   command in the Command window:

       DO test9.spr

6. Click the CONTACT field. Two WAIT windows appear with a name in each;
   press ENTER once for each window that appears. Press ENTER again to
   leave the field. One WAIT window will appear with a name, and then the
   error message will appear.

Additional reference words: FoxDos FoxWin 2.50 2.50a 2.50b 2.60 memvar KBCategory: kbprg kberrmsg kbprb KBSubcategory: FxsetupError


Last Reviewed: August 28, 1995
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.