How to Check for Changes Made in a Database Record

ID: Q97638

2.50 2.50a | 2.00 2.50 2.50a

WINDOWS    | MS-DOS
kbprg

The information in this article applies to:

SUMMARY

The UPDATED() function returns .T. if any GET field was changed during a READ command. Since push buttons, radio buttons, lists, invisible buttons, and spinners (spin boxes) are considered GET fields, UPDATED() will also return .T. if any of these controls are accessed during a READ command.

MORE INFORMATION

To write a simple code snippet to verify if any data in the current record was changed during a READ command, do the following:

1. When the record pointer is moved to a record, scatter the data to an

   array by issuing the following command:

      SCATTER TO beg_edit MEMO    && MEMO is required only if memo
                                   && fields are being verified.

   If the record pointer is pointing to the same record in more than one
   session, move the record pointer off the record and then back in order
   to get current information:

      SKIP     && provided we are not at EOF()
      SKIP -1  && to return to the same record
               && Now the second SCATTER will work correctly.

2. After all changes are complete, issue the following commands. Normally
   this code snippet would appear in the VALID clause of a push button or
   other control labeled to save the changes.

      * Scatter to a second array for comparison.
      SCATTER TO end_edit MEMO

      * Check each element in the array against the original data.
      FOR i = 1 TO alen(beg_edit)
        IF beg_edit(i) <> end_edit(i)
            * Return .F. if any element has changed.
            RETURN .F.
        ENDIF
      ENDFOR
      RETURN .T.

To check for changes during a BROWSE, execute the code in step 1 in a BROWSE WHEN user-defined function (UDF). Execute the code in step 2 in a BROWSE VALID UDF.

Notes

For more information, see the version 2.0 "Commands & Functions" manual or the version 2.5 "Language Reference" manual.

Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a test testing tell determine information data field compare comparison check "field change" KBCategory: kbprg KBSubcategory: FxprgBrowse

Keywords          : FxprgBrowse 
Version           : 2.50 2.50a | 2.00 2.50 2.50a
Platform          : MS-DOS WINDOWS

Last Reviewed: April 30, 1996