Sum function giving me an error (1 Viewer)

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Hello,

In one sub-form, I want to sum-up all the values of a particular calculated field ("PrixTot").
Therefore I have created a text box, put it in the foot part of the sub-form, and populated it with the Sum function: =Sum[(PrixTot]). But it gives me an error value "#Error"
I cant populate it with a query, as many values are calculated in the subform itself.

I send you the database, the form is "RECETTE", the subform "SF_PlatsIngredients", the text box "txtSousTotalPrix"
Many thanks in advance.
Pierre
 

Attachments

  • Garap.Agerria_BegiPrezio II.zip
    2.1 MB · Views: 34

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:00
Joined
May 7, 2009
Messages
19,245
here test your form.
i make the Total textbox unbound.
see the Current event of that subform.
 

Attachments

  • Garap.Agerria_BegiPrezio II.zip
    2.4 MB · Views: 42

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Fine work, I never used the form's recordset, I keep the method, many thanks!
 

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Sorry to bother you @arnelgp , I am having trouble rounding the figures: it should be 6.6*400 = 2640, however it does 400*6 = 2400.
I have tried Format, val(format(value,"0.00")) but wihout any success so far.
Could you help please?
Thanks in advance!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:00
Joined
May 7, 2009
Messages
19,245
which part is it? the one i made?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:00
Joined
Feb 28, 2001
Messages
27,186
When you see that kind of error, it means that whatever is holding the "6.6" thinks it is an integer, and it shouldn't be.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:00
Joined
May 7, 2009
Messages
19,245
i think it is Correctly calculating the Total.

here , open your form, RECETTE, and press Ctrl-G, to go to VBA.
on immediate window (if the Immediate window is not showing press Ctrl-G again)
you will see the calculation of the subform.
notice that it did a Two pass calculation (so you see it repeats).
but that is not the point, the point is it is correctly getting the correct value
from your table.
 

Attachments

  • Garap.Agerria_BegiPrezio II.zip
    2.2 MB · Views: 38

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Hello @arnelgp,
Many thanks for your help, however Val2 is rounded to the unit: "6" should be "6.6", "1" should be "1.18" etc..
I tried adding Format(...;"0.00"), but it doens't work.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:00
Joined
May 7, 2009
Messages
19,245
did you just test the db? if you did you will See that it is not Rounding.
open F_Recettes form. when it opens, press Ctrl-G to go to VBA and see the Immediate window for the calculation.
here is a snapshot:
result.png
 

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Yes, I did exactly what you told me, and the result is different:
 

Attachments

  • 1707055644222.png
    1707055644222.png
    181.6 KB · Views: 27

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:00
Joined
May 7, 2009
Messages
19,245
investigate your db/table. since i am getting the correct result and don't know if the db you posted is the same as the db you are working on.
 

Etxezarreta

Member
Local time
Today, 14:00
Joined
Apr 13, 2020
Messages
175
Ok. I have just downloaded the alst version you sent, and the matter remains!
 

Users who are viewing this thread

Top Bottom