ID: Q114671
The information in this article applies to:
The UPDATED() function returns .T. if any object has changed during a READ, or if a control such as a push button has been selected.
This article explains how you can also determine if the data itself has changed during a READ.
The READKEY() function provides an easy method of testing if the current user has made any modifications to the data during the READ. It does not test if another user has modified the same record residing on a network drive.
READKEY() can be used to return two distinct sets of values. If READKEY() is issued with no arguments, as in the following example, it returns a value in the range 0-36 if no data has changed, and 256-292 if data has changed:
   ?READKEY()
   ?READKEY(0)
The following steps will create a simple screen based on memory variables. A push button labeled Cancel will test if the data has been changed. If no data has been changed, the READ will terminate. If any data has been changed, a wait window will be displayed and the user will remain within the READ.
1. USE the CUSTOMER database in the TUTORIAL subdirectory. Create a quick
   screen based on memory variables.
      m.cancel = ""
      SCATTER MEMVAR
4. In the READ VALID snippet, enter the following code:
      IF READKEY(0) = 3     && Execute only if terminating button chosen
         IF readkey() > 255
            WAIT WINDOW "Can't cancel ... Data has changed"
            RETURN .F.      && Don't allow READ to terminate
         ELSE
            RETURN .t.      && Terminate READ
         ENDIF
      ENDIF
The value returned by READKEY() is valid only while the record pointer remains on the current record. If the record pointer is moved, READKEY() will reset to a value indicating that no data has been changed.
The code to test for the value of READKEY() must be located in the READ VALID snippet or in the Cleanup code, not in the VALID snippet of the push button. The value of READKEY() will not change until after the VALID snippet of the push button has been executed.
For additional information about how to test if data on disk has been changed by another user, please see the following article in the Microsoft Knowledge Base:
   ARTICLE-ID: Q97638
   TITLE     : How to Check for Changes Made in a Database Record
Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60 2.50c KBCategory: kbprg KBSubcategory: FxprgMultiuser
Last Reviewed: June 27, 1995