Subform Issue

I have created a form with many subforms related to the item in the main form. All the subforms work except for one. This one has a temp table behind it that is an accumulation of item ledger entries summed by “Item No.”, “Variant code”, “Location code” and “Unit Cost”. The subform actually populates correctly but every time I change item numbers in my main form I get a message saying “Temp Item Ledger Entry cannot be modified in this form”. It does actually update it so I can’t figure out why I’m getting this message. I have given the main form, subform and custom table all permissions for the table. This message looks just like the message you would see if you went directly into the item ledger entry table and tried to modify it.

The way I am populating this subform is to call a function in the subform from the OnAfterGetRecord of the main form. The subform does have the property SourceTableTemporary set to yes.

Main form:

Form - OnAfterGetCurrRecord()

CurrForm.UPDATECONTROLS;

CurrForm.CAPTION(“Document No.”);

//DSW-ARH 4/13/10 ++++++++++

IF (Type = Type::Item) AND

(“No.” <> ‘’) THEN

CurrForm.Stock.FORM.CreateSummary(“Document No.”,“No.”);

//DSW-ARH 4/13/10 ----------

Function in subform:

CreateSummary(DocumentNo : Code[20];ItemNo : Code[20])
QtyTotal := 0;
UnitCost := 0;
QtyAvailable := 0;

DELETEALL;

ILE.RESET;
ILE.SETCURRENTKEY(“Item No.”,“Variant Code”,“Location Code”);
ILE.SETRANGE(“Item No.”,ItemNo);
ILE.SETRANGE(Open,TRUE);
ILE.SETRANGE(Positive,TRUE);
IF ILE.FINDFIRST THEN REPEAT
ILE.CALCFIELDS(“Cost Amount (Actual)”,“Reserved Quantity”);
UnitCost := ILE.“Cost Amount (Actual)” / ILE.Quantity;
QtyAvailable := ILE.“Remaining Quantity” - ILE.“Reserved Quantity”;
QtyTotal := QtyTotal + (ILE.“Remaining Quantity” - ILE.“Reserved Quantity”);
IF NOT GET(DocumentNo,ILE.“Item No.”,ILE.“Variant Code”,ILE.“Location Code”,UnitCost) THEN BEGIN
INIT;
“Quote No.” := DocumentNo;
“Item No.” := ILE.“Item No.”;
“Variant Code” := ILE.“Variant Code”;
“Location Code” := ILE.“Location Code”;
“Unit Cost” := UnitCost;
“Qty. Available” := QtyAvailable;
“Qty. Total” := QtyTotal;
Quantity := ILE.Quantity;
“Remaining Quantity” := ILE.“Remaining Quantity”;
INSERT;
END ELSE BEGIN
“Qty. Available” += QtyAvailable;
“Qty. Total” += QtyTotal;
Quantity += ILE.Quantity;
“Remaining Quantity” += ILE.“Remaining Quantity”;
MODIFY;
END;
UNTIL ILE.NEXT = 0;

Any help would be appreciated.

Andy

you use the CLEAR function before reset.

CLEAR(ILE);

ILE.RESET;

Cheers.