ERROR MAKING "MODIFY" AFTER "TRANSFERFIELDS&q

foronavisionforonavision Member Posts: 79
Hello.

I'm using a form to copy records of a table. I use the instruction "TRANSFERFIELDS" to copy all the fields of one record to a new one and after this I modify two fields of this new record with new values. After this I use the instruction MODIFY but the next error message appears:

"Another user has modified the record for this my_table_name after you retrieved it from then database".

What do I have to do to copy all the fields? There are so many and I can't do this one by one.

Thank you very much!!

Comments

  • girish.joshigirish.joshi Member Posts: 407
    you get this error if the record variable you are working with isn't the latest copy of the record in the database.

    Are you performing these steps in different functions using different variables?

    In any case, you need to go "get", then do your changes, then a modify.
  • DenSterDenSter Member Posts: 8,307
    If you just make the changes in your first variable, you don't have to worry about all that, you can just use MODIFY.
  • Torben_R.Torben_R. Member Posts: 99
    Try this.

    Works for me everytime.
    RecordNew.INIT;
    RecordNew := TRANSFERFIELDS(RecordOld);
    RecordNew.Field1 := NewValueField1;
    RecordNew.Field2 := NewValueField2;
    .
    .
    RecordNew.INSERT;
    
  • foronavisionforonavision Member Posts: 79
    The destination record exits before I use transferfields but only with the two key fields completed so I can't use INSERT.
    May be posible to delete the existing record previously saving the existing fields values and after this use transferfields and insert?
  • krikikriki Member, Moderator Posts: 9,118
    Try this:
    "New Record".TRANSFERFIELDS("Old Record",FALSE); // FALSE doesn't copy the primary key fields
    "New Record".MODIFY(TRUE);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • foronavisionforonavision Member Posts: 79
    THAT'S THE SOLUTION!! THANK YOU VERY MUCH!!
Sign In or Register to comment.