Sum function giving me an error

Etxezarreta

Member
Local time
Today, 03:24
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

Fine work, I never used the form's recordset, I keep the method, many thanks!
 
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!
 
which part is it? the one i made?
 
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.
 
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

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.
 
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
 
Yes, I did exactly what you told me, and the result is different:
 

Attachments

  • 1707055644222.png
    1707055644222.png
    181.6 KB · Views: 68
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.
 
Ok. I have just downloaded the alst version you sent, and the matter remains!
 

Users who are viewing this thread

Back
Top Bottom