Dear all,
I’m trying to “Sum” details fields , within a “New field” field on Master part of Master/Detail form.
Master table: dayly_out_m
Details: dayly_out (here there is the field “quantity” I need to sum on master part of form).
Added field (only for showing the total of sum): somma_qty.
I’ve seen on forum some posts and I wrote following lines.
sc_lookup(dataset,“SELECT SUM(quantity)
FROM dayly_out
WHERE dayly_out.id_dayly_out_m = {id_dayly_out_m}
AND dayly_out.date = {date}”);
$somma_qty = {dataset[0][0]};
sc_master_value(‘somma_qty’, $somma_qty);
echo sc_master_value(‘somma_qty’, $somma_qty);
As … always nothing happens… ;-((
I’ve also tried this with no results.
sc_lookup(dataset,“SELECT SUM(quantity)
FROM dayly_out
WHERE dayly_out.id_dayly_out_m = {id_dayly_out_m}
AND dayly_out.date = {date}”);
$somma_qty = {dataset[0][0]};
{somma_qty} = $somma_qty;
echo {somma_qty};
I wrote it within onLoad events of Master part of forms.
Probably I think I’m wronging code and also event. The big doubt, on the other hand, is concerning the functioning of sc_lookup used on added form fields. The same problem of previous post. Could it be a bug ?
Is it correct to use SELECT SUM in this way ? On mysql it works right !
Many thanks
Giovannino