Here is an example of how to use the Rec/xRec pair of records. In an application, data is stored in
two tables, a header table and a line table. The header table contains general information about,
for example, sales orders, while the line table contains the specific order lines. The form that you
use to enter information into the header table has fields that contain the customer’s address.
These fields are related to the Customer table, and can be filled out by using a lookup function in
the field that establishes the relationship. In the header table, only the customer number is stored,
and the other fields with customer information (name, address, and so forth) are retrieved from the
Customer table when the Customer No. field is validated.
Now, should the user be able to change the customer number? In some situations the answer
would be yes, in others no. If the order has already been shipped, the answer should definitely be
no, but there could be situations where it would be yes – it should, for example, be possible to
correct an erroneous number on an order that has not been processed completely.
You could do something like this:
– When validating the customer number field, check whether or not the order has been shipped.
– If it has been shipped, compare the customer number fields in the xRec and Rec records. If they
differ, reject the change.
In real life, you would certainly add some more checks and some user dialog, but this is the basic
idea.
Comments
Regarding xRec look at table 36 Sell-to Customer No. - OnValidate() to see how xRec is used. Enable the debugger, activate that trigger from your client and see what happens.
In this example ("Sell-to Customer No." <> xRec."Sell-to Customer No.") when yo uenter or modify the value of the field the trigger is activated. xRec contains the value of the record before your action and Rec contains the new value. This way you can check what field got changed.
You are right. The dataport doesn´t see xrec.
I´ll try the example from the table 36 Sell-to Customer No.
Thank you!
http://www.BiloBeauty.com
http://www.autismspeaks.org