Sub Form

jsshivalikjsshivalik Posts: 43Member
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 Posts: 16Member
    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 Posts: 1,564Member
    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
  • BlackTigerBlackTiger Posts: 1,144Member
    edited 2018-05-30
    1. never use FINDFIRST if you're going to loop after it
    2. re-read NAV Developer's manual and learn NAV dev standards
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
Sign In or Register to comment.