Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting changes in field
Message
From
07/11/2004 05:18:18
 
 
To
06/11/2004 11:26:35
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 7 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00958830
Message ID:
00958961
Views:
15
>I have a pageframe. In each pages I have to detect when a change has been made in one of the field on that page. I'll then update the "Date of the last change" field.
>
>My question : What would be the best way to detect if a field was changed.
>
>I'm thinking of first gather the values when I get in the page and then gather again when user leaves the page. If a change is detected then I update the date.
>
>Am I on the right track or is there a better way to do this?
>
>Is there a function (native) in VFP to compare values for the result of the two gather? Otherwise what do you suggest as the most efficient way to do this?

Denis,

GetFldState() tells whether a field has been modified. It does not compare the old contents and the new contents. It may return TRUE even if the field's contents are equal to the original

I use the function below. You need at least record buffering. If you use it in the Record Validation Rule you do not need any buffering at all.

btw, you can update the date in the record validation rule. Then you have only one place where the date is modified
*--------------------------------------------------------------------------
function FieldChanged(FieldName)

	do case
	case isnull(oldval(FieldName)) or Isnull(eval(FieldName))
		return (isnull(oldval(FieldName)) <> Isnull(eval(FieldName)) )
	otherwise
		return (oldval(FieldName) <> eval(FieldName))
	endcase
endfunc
*-------------------------------------------------------------------------
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform