WITH THIS IF .IsNew() lcTrans_Relateds_pk = cTrans_Relateds_pk .cAction_code = 'AD' REPLACE cRelateds_fk WITH IIF(cTrans_Relateds_pk == lcTrans_Relateds_pk, v_Relateds.cRelateds_pk, cRelateds_fk) ; cTrans_fk WITH THISFORM.cTrans_pk, ; iGuarantor_flag WITH 1, ; iPrimary_flag WITH IIF(cTrans_Relateds_pk == lcTrans_Relateds_pk,1,0) ALL ELSE .cAction_code = 'CH' ENDIF .lSaveTransEvents = .T. .cDetail_Info = "" .cFunction_Code = "GU" .cTrans_fk = THISFORM.cTrans_pk ENDWITHHowever, after I clicked on save button, only the last new record is get updated. The other records remain the same and the iPrimary_flag is still 1 for them. I'm using TABLEUPDATE(.t.,.t.) If I'm doing it slowly using the debugger, it usually updates correctly.