[Solved] Show running total of value

Discuss the database features
Post Reply
PMarcotte
Posts: 8
Joined: Wed Jan 25, 2017 3:53 am

[Solved] Show running total of value

Post by PMarcotte »

Hi,

I've looked, read and studied a bunch of things, but I can't seem to get the information I want: How can I show the total value of the current form? I get the total of all forms, not the current one. Can someone tell me how to do this?

I want the listbox "Coûtant" in form "F_GestionBijou" to show the total of the current items selected. The names and various entries are all rubbish, I just want to get the structure to work. I'll deal with the actual values later.

Thank you.
Attachments
002.odb
(85.11 KiB) Downloaded 122 times
Last edited by PMarcotte on Tue Oct 10, 2017 6:18 pm, edited 1 time in total.
OpenOffice 4.1.3 on Windows 7
eremmel
Posts: 1080
Joined: Tue Dec 30, 2008 1:15 am

Re: Show running total of value

Post by eremmel »

With "o show the total of the current items selected" you mean the data of the grid? Put your Coûtant in the same (sub)form/formulaire with help of the Form Navigator.
It's Microsoft marketing that tells you computers are qualified for non-technicians
W11 22H2 (build 22621), LO 7.4.2.3(x64)
PMarcotte
Posts: 8
Joined: Wed Jan 25, 2017 3:53 am

Re: Show running total of value

Post by PMarcotte »

Thank you for your response. That is exactly what I mean. I've tried that, it gives the same result.
OpenOffice 4.1.3 on Windows 7
eremmel
Posts: 1080
Joined: Tue Dec 30, 2008 1:15 am

Re: Show running total of value

Post by eremmel »

You need a different subform for this with the right query. See attachment.
Attachments
002a.odb
Sub-total
(84.59 KiB) Downloaded 149 times
It's Microsoft marketing that tells you computers are qualified for non-technicians
W11 22H2 (build 22621), LO 7.4.2.3(x64)
PMarcotte
Posts: 8
Joined: Wed Jan 25, 2017 3:53 am

Re: Show running total of value

Post by PMarcotte »

Perfect! Now I can use this elsewhere. Thank you! :super:
OpenOffice 4.1.3 on Windows 7
eremmel
Posts: 1080
Joined: Tue Dec 30, 2008 1:15 am

Re: [Solved] Show running total of value

Post by eremmel »

Please do not take the route of private message to discuss your (sub question).
When you get an error mention the error as well. People helping here have some technical experience but lack supernatural knowledge (there are other forums for that).
You should start study a few things about SQL like GROUP BY. Each SELECT-expression that is not an aggregation function (like SUM() ) should be part of the GROUP BY clause as well. So your query might become:

Code: Select all

SELECT  sum("T_BijouDetail"."Qte" * ("T_Item"."PrixQte" / "T_Item"."QteAchat")) as "Price"
	, "T_BijouDetail"."ID_Bijou" 
	, "T_Item"."ID"
FROM "T_BijouDetail", "T_Item"
WHERE "T_BijouDetail"."ID_Item" = "T_Item"."ID"
GROUP BY "T_BijouDetail"."ID_Bijou"	, "T_Item"."ID"
But this does not sum up anything and you need now a double relation on your sub form. I guess you need

Code: Select all

SELECT  sum("T_BijouDetail"."Qte" * ("T_Item"."PrixQte" / "T_Item"."QteAchat")) as "Price"
	, "T_BijouDetail"."ID_Bijou" 
FROM "T_BijouDetail", "T_Item"
WHERE "T_BijouDetail"."ID_Item" = "T_Item"."ID"
GROUP BY "T_BijouDetail"."ID_Bijou"	
I never design my SQL with the GUI interface for it is limited and I do not understand the logic. With the change you made to the query you missed the analogy between my example and what you did: no Function sum over your expression in Field.
It's Microsoft marketing that tells you computers are qualified for non-technicians
W11 22H2 (build 22621), LO 7.4.2.3(x64)
Post Reply