Sub Form

jsshivalikjsshivalik Member Posts: 67
Hi

I have Location table as Main and Custom Table Issue Lines on Sub Form. I have set temporary table as the source of the subform
CDNLine is of Record Data Type with SubType Issue Lines.

I have written below code on Push of button but it is not displaying any data in SubForm.

TEntry.RESET;
TEntry.SETCURRENTKEY("Location",Date);
TEntry.SETRANGE("Location","No.");
TEntry.SETRANGE(Date,TempDate,WORKDATE);
IF TEntry.FINDFIRST THEN REPEAT
Amount := 0;
TPLine.RESET;
TPLine.SETRANGE("Location","No.");
TPLine.SETRANGE(Date,TempDate);
IF TPLine.FINDFIRST THEN REPEAT
Amount += TPLine."Amount";
UNTIL TPLine.NEXT = 0;

IF Amount > 0 THEN BEGIN
CDNLine.RESET;
CDNLine.SETRANGE("Location","No.");
CDNLine.SETRANGE("Sale Date",TempDate);
IF CDNLine.FINDFIRST THEN BEGIN
CDNLine."Sale Amount" := Amount;
CDNLine.MODIFY;
END ELSE BEGIN
CDNLine.INIT;
EntryNo := EntryNo + 1;
CDNLine.VALIDATE("Location","No.");
CDNLine.VALIDATE("Entry No",EntryNo);
CDNLine.VALIDATE("Sale Date",TempDate);
CDNLine.VALIDATE("Sale Amount", Amount);
CDNLine.INSERT;
END;
END;
TempDate := TempDate + 1;
UNTIL TempDate > WORKDATE;
CurrForm.UPDATE(TRUE);




Thanks

Answers

  • welanderwelander Member Posts: 20
    You need to call you code on Rec at the subform, you can do that by making a function on the subform which can be called from a button on the main form, and then change your code to match.
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Your code would be really MUCH easier to read if you did bother to use this little function : k2hb9lxxbd2c.png
    It is only two clicks.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.