Checking if data changed in a form 
Author Message
 Checking if data changed in a form
I tought that I could use oldval() and curval() functions to check if I
changed the values of a field.  This did not seem to work.  I am using
optimistic record locking.  This will eventually be multi-user but also need
to check if current user changed data and then log fields that changed.


Sat, 14 Apr 2001 03:00:00 GMT
 Checking if data changed in a form

Quote:

> I tought that I could use oldval() and curval() functions to check if I
> changed the values of a field.  This did not seem to work.  I am using
> optimistic record locking.  This will eventually be multi-user but also need
> to check if current user changed data and then log fields that changed.

You don't mention which version of Foxpro you are using.. but in general
it is not a good idea to let form fields modify tables directly if you
can help it. If you pass the data through memory variables.. you can
sence the changes much more easily. Anyway... this how I do this ;o)

--
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com



Sat, 14 Apr 2001 03:00:00 GMT
 Checking if data changed in a form

Quote:


>> I tought that I could use oldval() and curval() functions to check if I
>> changed the values of a field.  This did not seem to work.  I am using
>> optimistic record locking.  This will eventually be multi-user but also
need
>> to check if current user changed data and then log fields that changed.

I am using buffering in VFP 5.
Quote:

>You don't mention which version of Foxpro you are using.. but in general
>it is not a good idea to let form fields modify tables directly if you
>can help it. If you pass the data through memory variables.. you can
>sence the changes much more easily. Anyway... this how I do this ;o)

I thought the who idea behind buffering was that it was nolonger necessary to
use memory vairables (i.e. scatter/gather) and that changes where not
reflected in the table untill an explicit tableupdate was issued.
Quote:
>--
>Chuck Maier
>CDM Consulting Services
>http://www.cdmcon.com



Sun, 15 Apr 2001 03:00:00 GMT
 Checking if data changed in a form

Quote:



> >> I tought that I could use oldval() and curval() functions to check if I
> >> changed the values of a field.  This did not seem to work.  I am using
> >> optimistic record locking.  This will eventually be multi-user but also
> need
> >> to check if current user changed data and then log fields that changed.

> I am using buffering in VFP 5.

> >You don't mention which version of Foxpro you are using.. but in general
> >it is not a good idea to let form fields modify tables directly if you
> >can help it. If you pass the data through memory variables.. you can
> >sence the changes much more easily. Anyway... this how I do this ;o)

> I thought the who idea behind buffering was that it was nolonger necessary to
> use memory vairables (i.e. scatter/gather) and that changes where not
> reflected in the table untill an explicit tableupdate was issued.

That's right.  With buffering, you need not do any
shuffling of data into and out of variables to
guard the tables from immediate updates.  You have
the TABLEUPDATE and TABLEREVERT commands to handle
the processing of the updates.  Also there is
BEGIN TRANSACTION, ROLLBACK, and END TRANSACTION if
you need to do atomic updates.

If you are not seeing what you expect using OLDVAL and
CURVAL, I suspect that you either do not have buffering
enabled on the table in question, or are not using and
interpreting OLDVAL and CURVAL correctly.  

CURVAL returns the value from disk, OLDVAL returns the
value that was originally buffered.  So if you are in
a single user environment, chances are these two will
be the same.  If you want to use this method to detect
changes (instead of GETFLDSTATE, which I tend to use),
then you should compare OLDVAL to the value in the
corresponding control, not to CURVAL.

-- TRW



Sun, 15 Apr 2001 03:00:00 GMT
 Checking if data changed in a form

To hopefully answer my own question using GETFLDSTATE and EVAL functions
seems to work.

Quote:



>> >> I tought that I could use oldval() and curval() functions to check if I
>> >> changed the values of a field.  This did not seem to work.  I am using
>> >> optimistic record locking.  This will eventually be multi-user but also
>> need
>> >> to check if current user changed data and then log fields that changed.

>> I am using buffering in VFP 5.

>> >You don't mention which version of Foxpro you are using.. but in general
>> >it is not a good idea to let form fields modify tables directly if you
>> >can help it. If you pass the data through memory variables.. you can
>> >sence the changes much more easily. Anyway... this how I do this ;o)

>> I thought the who idea behind buffering was that it was nolonger necessary
to
>> use memory vairables (i.e. scatter/gather) and that changes where not
>> reflected in the table untill an explicit tableupdate was issued.

>That's right.  With buffering, you need not do any
>shuffling of data into and out of variables to
>guard the tables from immediate updates.  You have
>the TABLEUPDATE and TABLEREVERT commands to handle
>the processing of the updates.  Also there is
>BEGIN TRANSACTION, ROLLBACK, and END TRANSACTION if
>you need to do atomic updates.

>If you are not seeing what you expect using OLDVAL and
>CURVAL, I suspect that you either do not have buffering
>enabled on the table in question, or are not using and
>interpreting OLDVAL and CURVAL correctly.  

>CURVAL returns the value from disk, OLDVAL returns the
>value that was originally buffered.  So if you are in
>a single user environment, chances are these two will
>be the same.  If you want to use this method to detect
>changes (instead of GETFLDSTATE, which I tend to use),
>then you should compare OLDVAL to the value in the
>corresponding control, not to CURVAL.

>-- TRW



Sun, 15 Apr 2001 03:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Change data type without no checking to the existing data

2. CDML: Password check and change in one form?

3. Changing data on form by choosing value in (db)combo with data control

4. Change table check constraint to column check constraint?

5. How to check if data has been changed

6. Unique Check for Forms 6 Data Block

7. HOW: Force changed data to display in form

8. RecordSource change not reflected in data form

9. MSAccess: Updating open forms after changing data

10. Changing Data Environment w/Grid Forms

11. How to change Data Source of a form and report

12. Detect Data Change At Form Level


 
Powered by phpBB® Forum Software