Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formula to check if field modified

Status
Not open for further replies.

hume

Technical User
Aug 5, 2002
16
AU


What would the formula be to check if a field has been modified , can someone please start me off.

thankyou
 
You have three methods of checking for field value change : via formulas, java or script.

Using formulas it is slightly complicated. You need to place a field at the top of the form, computed when composed, computed to empty.
Then you need to put another field after the place on the form where you have the field you want to control, set to computed, and check in that field whether the value of the top field is the same as the value of the field you want to control.
Finally, you'll need a field at the bottom of the form, set to computed, where you save into the top-form field the current value of the field you are controlling, but only if the document is being saved.

So, after all this theory, how is it going to pan out ?
Lets say you want to control the field named Phone. At the top of the form, create a field named PhoneCheck1, computed when composed to
Code:
""
.
Then, a line under the Phone field, create a PhoneCheck2, computed to
Code:
@if(phone!=PhoneCheck1;0;1)
.
Finally, a PhoneCheck3 field at the bottom, Computed to
Code:
@if(@isdocbeingsaved;@do(FIELD PhoneCheck1:=Phone);"")[code].

So this setup will alert you if the contents of the Phone field change during the edition of the document. It is up to you to decide what you want to do if the PhoneCheck2 field is set to 0.

Using Java it is a bit easier, since you have the OnChange event directly in the Field properties. You can then trigger something to execute (like an Agent) on the document when a change is made, without worrying about multiple field controls.

With script it is at once easier and slightly more difficult than Java. More difficult because you have two code areas to use to control change, easier because you can check on multiple fields in the same code area.
I'm talking about the QueryOpen and QuerySave form events. In the Global Declarations area of the form, declare a variable corresponding to your field type (do NOT use variants unless you are highly skilled in converting their type for control purposes).
In the QueryOpen event, just assign the current value of the field to the variable.
In the QuerySave event, all you need to do is recheck the current field value against the saved variable value.
Then you have to decide what to do about it.

Hope this helps,

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top