Hi guys.
I recently had a problem where I wanted to automatically update Date on my Line when I change the date on Header. Also, I wanted to display a dialog that will ask me if I want to change the date since there are already some Lines for that header. I solved it by adding this code to my Header table. Cheers
OnInsert()
...
...
Posting Date - OnValidate()
UpdateLines(FIELDCAPTION("Posting Date"),CurrFieldNo <> 0);
...
...
LOCAL LinesExist() : Boolean
Line.RESET;
Line.SETRANGE("Header No.","No.");
EXIT(Line.FINDFIRST);
LOCAL UpdateLines(ChangedName : Text[250];AskQuestion : Boolean)
IF NOT LinesExist THEN
EXIT;
IF AskQuestion THEN
Question := STRSUBSTNO(Txt1,ChangedName);
IF GUIALLOWED THEN
IF DIALOG.CONFIRM(Question,TRUE) THEN BEGIN
END
ELSE
EXIT;
Line.LOCKTABLE;
MODIFY;
Line.RESET;
Line.SETRANGE("Header No.","No.");
IF Line.FINDSET THEN BEGIN
REPEAT
CASE ChangedName OF
FIELDCAPTION("Posting Date"):
IF Line."Header No." <> '' THEN BEGIN
Line.VALIDATE("Price Date","Posting Date");
Line.MODIFY;
END;
END;
UNTIL Line.NEXT = 0;
END;
Comments