SETFILTER("Customer Type",'Chain');
SETRANGE("Price Group Code",'140');
IF "Frozen-Special Price".FIND('-') THEN
REPEAT
"Price Group Code":= 'AALFS';
"Frozen-Special Price".MODIFY;
UNTIL "Frozen-Special Price".NEXT = 0;
First: I'am wondering, why you use the Rec Variable "Frozen-Special Price" for the loop, but you change the the CurrRec. Or is there an With "Frozen-Special Price" Do begin statement infront of?
From where is this code called :?: OnPreDataItem / OnPostDataItem / OnAfterGetRecord (as David sayed)
normally u make a rename like this:
SpecialFroznPrices.reset;
SpecialFroznPrices.SETFILTER("Customer Type",'Chain');
SpecialFroznPrices.SETRANGE("Price Group Code",'140');
IF SpecialFroznPrices.FINDset(true,true) THEN begin //onSQL, Native find('-') with an sep. Rec Variable to rename
REPEAT
SpecialFroznPrices.rename(PKField1,'AALFS',[PKField N]; //if Price Group is the second Primary key field
"Frozen-Special Price".MODIFY;
UNTIL SpecialFroznPrices.NEXT = 0;
end;
an other way is following (if there are no tabl. relations)
TempSpecialFroznPrices.reset; //temp. Variable
TempSpecialFroznPrices.deleteall;
SpecialFroznPrices.reset;
SpecialFroznPrices.SETFILTER("Customer Type",'Chain');
SpecialFroznPrices.SETRANGE("Price Group Code",'140');
IF SpecialFroznPrices.FINDset(true) THEN begin
REPEAT
TempSpecialFroznPrices := SpecialFroznPrices;
TempSpecialFroznPrices.insert;
UNTIL SpecialFroznPrices.NEXT = 0;
end;
SpecialFroznPrices.deleteall;
TempSpecialFroznPrices.reset;
if TempSpecialFroznPrices.find('-') then begin
repeat
SpecialFroznPrices.init;
SpecialFroznPrices := TempSpecialFroznPrices;
SpecialFroznPrices."Price Group Code":= 'AALFS';
SpecialFroznPrices.insert;
until TempSpecialFroznPrices.next = 0;
end;
Comments
You need to use the RENAME command directly on the record instead of validating then modifying the record.
Is this a one of fix? If so then fine. But if this is a regular routine, then you need to redefine the data model.
For the price table, there are no table relations to these field so you can also:
Copy the rec, delete the rec, change the needed field in copy, insert the rec from copy.
But if you are not sure if this work for u, use, like David say, the Rename command.
Regards
This is the code I got on a report to change the values on the field
SETFILTER("Customer Type",'Chain');
SETRANGE("Price Group Code",'140');
IF "Frozen-Special Price".FIND('-') THEN
REPEAT
"Price Group Code":= 'AALFS';
"Frozen-Special Price".MODIFY;
UNTIL "Frozen-Special Price".NEXT = 0;
Is this code in the on after get record trigger in the report? The context does not make sense. What is the WITH here?
First: I'am wondering, why you use the Rec Variable "Frozen-Special Price" for the loop, but you change the the CurrRec. Or is there an With "Frozen-Special Price" Do begin statement infront of?
From where is this code called :?: OnPreDataItem / OnPostDataItem / OnAfterGetRecord (as David sayed)
normally u make a rename like this:
Regards
Oh and this is just so wrong in more ways than I can even imagine.