I got a problem for filling up a temporary table inside a subform... This temp table is the sourcetable from this subform
In my mainform i execute the following code:
Form - OnAfterGetRecord()CurrForm.GrondStofSamenStellingSub.FORM.SetProductCode(ID);
CurrForm.GrondStofSamenStellingSub.FORM.FillTempTable;
When i now switch from tabpage, this OnAfterGetRecord gets executed again. This leads to problems cause the FillTempTable get executed again
SetProductCode(ReceptID : Integer)
gv_ReceptID := ReceptID;
FillTempTable()
// Opvullen van Temp table
lv_ReceptItem.RESET;
lv_ReceptItem.SETRANGE(lv_ReceptItem.ReceptID,gv_ReceptID);
lv_ReceptItem.SETFILTER(lv_ReceptItem.ReceptItem,'<>%1','');
IF lv_ReceptItem.FINDFIRST THEN BEGIN
REPEAT
IF lv_Item.GET(lv_ReceptItem.ReceptItem) THEN BEGIN
Rec.Grondstof := lv_Item."No.";
Rec.Type := lv_Item."Item Category Code";
Rec.Omschrijving := lv_Item.Description;
Rec.Hoeveelheid := lv_ReceptItem.Hoeveelheid;
Rec.Percentage := lv_ReceptItem.Percentage;
Rec.INSERT;
COMMIT;
END;
UNTIL lv_ReceptItem.NEXT = 0;
END;
CurrForm.UPDATE(FALSE);
The FilltempTable creates an error cause it will insert duplicate values...
0
Comments
So not in the onaftergetrecord of the mainform...
Put your code in the AfterGetCurrRecord
Albert
I think it would be rather simple to make a variable to store the current "ProductCode" and set it up so that if that same "ProductCode" is issued again, do nothing.
But for starters, why separate the one function into two? You're calling both at the same place no matter what.
You don't need COMMIT since you're writing to a temporary table (aka not the actual database)