I have a subform which contains a list of payments and dates. When the user proceeds to the next blank line on my subform, I populate the payment amount with the amount from the preceeding line and the date with the date from the previous line plus 1 month.
I have added the following code to the OnNewRecord trigger :
IF BelowxRec THEN
BEGIN
IF (xRec."Posting Date" <> 0D) AND (xRec.Amount <> 0)
AND (TotalLineAmount < PrepaymentHeader."Prepayment Amount") THEN
BEGIN
RemainingAmount := PrepaymentHeader."Prepayment Amount" - TotalLineAmount;
"Posting Date" := CALCDATE('1M',xRec."Posting Date");
IF xRec.Amount <= RemainingAmount THEN
Amount := xRec.Amount
ELSE
Amount := RemainingAmount
END;
END;
TotalLineAmount is a running total of the lines on the subform. This gets updated by the OnInsertRecord, OnModifyRecord and OnDeleteRecord triggers. PrepaymentHeader."Prepayment Amount" is the maximum allowable value for TotalLineAmount, from the mainform Sourcetable.
The code works, up to a point. When the user moves down to a blank line, the date and amount fields are populated correctly. But then the user cant proceed to create any more lines. The new line never gets inserted. If the user moves back up to the previous line, the newline disappears.
Autosplitkey is TRUE.
MultipleNewLines and DelayedInsert are both FALSE and changing their values doesnt make any difference ...
0
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
"Would you like to insert a new line" Yes/No or would that be too annoying?
http://www.BiloBeauty.com
http://www.autismspeaks.org
Is there some way that a confirm message could help ? I tried adding an INSERT statement to the OnNewRecord trigger, but that trigger is not within a 'write transaction' ... ie, you cant update the database from there.
Thanks for your suggestion though.
currform update or table insert command would run
IF CONFIRM('Would You Like To Add A New Line?',TRUE)
THEN blag blah blah
sombody is going to have to click something somewhere - even if it's just some phoney boolean field on the line.
http://www.BiloBeauty.com
http://www.autismspeaks.org
We are fighting a battle to win over a key individual at a new client. They have just migrated from another system and are complaining that certain functions within Dynamics are much more 'long-winded'. So I am trying to give them comparable functionality to their old system.
As you suspected, I dont think the prompt on each new line is going to be impress them.
That will teach me !! I assumed "Anything that old system can do, Dynamics can do better ...".
1. create automation variable WshShell using automation server Windows Script Host Object Model, WshShell class
2. Code...
OnNewRecord trigger:
CLEAR(WshShell);
CREATE(WshShell);
WshShell.SendKeys('{HOME}');
WshShell.SendKeys('{TAB}');
Bob
NY
Problem solved =D> That worked a treat.
I know with some automation objects there can be a problem with compiling objects on site. Is Windows Script Hosting pretty universal ?
Thank you
Bob
To the best of my knowledge, Windows script hosting is pretty universal and is included with any Windows os.
yw
Bob
Bob
NY