DOCUMENT:Q121344  09-NOV-1994  [FOXPRO]
TITLE   :PRB: Variable Defined in WHEN Not Found in VALID
PRODUCT :Microsoft FoxPro
PROD/VER:2.5x 2.60 | 2.5x 2.60
OPER/SYS:WINDOWS   | MS-DOS
KEYWORDS:kbprg kberrmsg

--------------------------------------------------------------------
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
KBSubcategory:

=============================================================================

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.

Copyright Microsoft Corporation 1994.