Rec and xrec

nav_studentnav_student Member Posts: 175
I read from a book the explanation of the difference between a record and a Xrec but i don´t now why to aply this knowledge.

I have Table1 with Field1, Field2, Field3.

I have create a dataport that runs if the user clicks on a Command Button, on a form. Dataport is importing data from a txt file to a table.

I want to validate that if the information that comes from my text file is the same on Field1 the dataport do not copythe information to my table. I was searching on C/SIDE Reference guide and on Microsoft manuals but i do not see an example of how can i apply this.

Thanks for your answers

Best Regards,

Nav_Student





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

  • kapamaroukapamarou Member Posts: 1,152
    Your dataport does not have xRec functionality. You should change your dataport properties or add code to skip the record.

    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.
  • nav_studentnav_student Member Posts: 175
    Thanks kaspamarou.

    You are right. The dataport doesn´t see xrec.

    I´ll try the example from the table 36 Sell-to Customer No.

    Thank you!
  • SavatageSavatage Member Posts: 7,142
    Are those 3 fields Key fields in your table? If so you can look into using the AutoUpdate & AutoReplace properties of the dataport.
Sign In or Register to comment.