DSum Function Calculation

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

DSum Function Calculation

Post by grovelli »

In the startup form of the mdb you find here (as SQL.zip, couldn't shrink it down to 200k), select 15 July 2010, then click the Report Preview button. The only text box in the report displays 7381956 while the correct sum for the values of the OreMarcia field from the 1st January 2010 to 15th July 2010 should give 262440. Can anybody see what causes the mismatch?

User avatar
HansV
Administrator
Posts: 78488
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DSum Function Calculation

Post by HansV »

In a situation like this, you should remove all records that aren't relevant to the problem at hand. We don't really need more than a 100,000 records to analyze a problem. I bet you could have reduced the database to a more manageable size than 19 MB that way!

The relevant field in dbo_c_LetturaGiornalieraSTD is named data, not giorno, so the expression should be

=IIf(IsNull([giorno]),Null,DSum("oremarcia","dbo_c_LetturaGiornalieraSTD","data between #" & Format(DateSerial(Year([giorno]),1,1),"mm/dd/yyyy") & "# and #" & Format([giorno],"mm/dd/yyyy") & "# and IdImpianto = 17 and gruppo = 1"))
Best wishes,
Hans

grovelli
4StarLounger
Posts: 528
Joined: 26 Jan 2010, 15:14

Re: DSum Function Calculation

Post by grovelli »

:clapping: :thankyou: Hans