How to Use READKEY() to Test If Data Has Been ChangedLast reviewed: June 27, 1995Article ID: Q114671 |
The information in this article applies to:
SUMMARYThe 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.
MORE INFORMATIONThe 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()If any numeric argument is specified, as in the following example, READKEY() returns a value in the range 1-6, indicating the method used to terminate the READ:
?READKEY(0)For information about possible READKEY() return values, refer to the "Language Reference" or the FoxPro Help file. 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.
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.
REFERENCESFor 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 RecordIn a multiuser environment, you may need to use both techniques in order to guarantee data integrity.
|
Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b 2.60
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |