Table already exist Identification fields and values.. even though the record is unique

I having an error when running this script:


TransSales.DELETEALL;

Store.RESET;
Store.SETFILTER("No.",'<>%1','');
IF Store.FINDFIRST THEN BEGIN
REPEAT
TransSalesTransform.RESET;
TransSalesTransform.SETCURRENTKEY("Store No.","POS Terminal No.","Transaction No.","Line No.");
TransSalesTransform.SETRANGE("Trans. Date",CALCDATE('-1D',RunDate),RunDate);
TransSalesTransform.SETRANGE("Store No.",Store."No.");
IF TransSalesTransform.FINDSET THEN BEGIN
REPEAT
TransSales.INIT;
TransSales."Store No." := TransSalesTransform."Store No.";
TransSales."POS Terminal No." := TransSalesTransform."POS Terminal No.";
TransSales."Transaction No." := TransSalesTransform."Transaction No.";
TransSales."Line No." := TransSalesTransform."Line No.";
TransSales."Active Location Code" := Store."Location Code";
TransSales."Trans. Date" := TransSalesTransform."Trans. Date";
TransSales."Item No." := TransSalesTransform."Item No.";
TransSales.Quantity := TransSalesTransform.Quantity;
TransSales."Trans. Time" := TransSalesTransform."Trans. Time";
TransSales.INSERT;
UNTIL TransSalesTransform.NEXT = 0;
END;
UNTIL Store.NEXT = 0;
END;


The Primary Keys of TransSales and TransSalesTransform is: Store No.,POS Terminal No.,Transaction No.,Line No.


It runs properly until a certain record saying that it is already exist when inserting even though it is not, also the record on TransSales is being deleted first before inserting data. I'm not sure if the FINDSET is repeating the same record on the source table (TransSalesTransform).

Thank you in advance!

Here is the image error:  

It says already exist but that table has no record.

Parents Reply Children
No Data
Related
Recommended