I have a Master/Detail form, where I need a total for each row of the detail form and then I need to sum those and display it on the Master form. I have it mostly working but there are two bugs.
[SOLVED]On both version 7 and 8, when the Master/Detail is run the sum shown on the Master form is initially 99.9999, which I guess is undefined or overflow. Once I make a new or update an entry on the Details form it corrects the sum on the Master form.[/SOLVED]
Separately, if I am using version 7 then on the Details form the totals work fine so long as I change focus to another field before you click the ‘update row’ button.
If I am using version 8 then instead the sum on the Master form does not update unless I change focus to another field with in the Details form before clicking the ‘update row’ button.
My updMaster function for updating the master form is:
[HR][/HR]sc_lookup(dataset, “SELECT SUM(price * (yxs+ys+ym+yl+yxl+yxxl+ysize+
axxs+axs+asm+am+al+axl+axxl+a3xl+a4xl+a5xl))
FROM items
WHERE OrderID = ‘{OrderID}’”
);
$subtotal = number_format( {dataset[0][0]}, 2, ‘,’, ‘.’);
sc_master_value(‘subtotal’, $subtotal);
$subtotal = {dataset[0][0]};
sc_exec_sql(“UPDATE orders
SET subtotal = $subtotal
WHERE OrderID = ‘{OrderID}’”
);
[HR][/HR]Just like the Master/Detail example, this is run onAfterInsert, onAfterUpdate, and onAfterDelete on the Detail form. Adding this to onLoadRecord and onLoad made no difference.
My setTotal function for determining totals on the Detail form is:
[HR][/HR]{ItemTot} = {price} * ({yxs}+{ys}+{ym}+{yl}+{yxl}+{yxxl}+{ysize}+{axxs}+{axs}+{asm}+{am}+{al}+{axl}+{axxl}+{a3xl}+{a4xl}+{a5xl});
[HR][/HR]Just like the Master/Detail example, this is run for every field that is required for the calculation as an onChange on the Detail form. I also added this to the onLoadRecord so the total field will be calculated when it first loads. Adding this to any and all the other Events makes no difference.
Any ideas how to fix this?
P.S. It seems the example code they show you on http://www.scriptcase.net/scriptcase-samples/tutoriais/form/form38.php do not match the application that supposedly runs from it http://www.scriptcase.net/sistemas/v7/exemplos/form38/ . I have had similar experience with the video tutorials code not matching the application.