ACC: Incorrect Results Received with DSum() Function

Last reviewed: May 28, 1997
Article ID: Q97000
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SYMPTOMS

Moderate: Requires basic macro, coding, and interoperability skills.

When you run a DSum() function, you receive incorrect results.

CAUSE

The DSum() function returns a set of values in a specified set of records (domain). Typically, you use this function in a text box control on a report to total the values from a field in a table or query.

If you omit the surrounding quotation marks from the expression argument, you don't see the expected error message. Instead, you see a value that is derived by taking the last value of the field from the report and summing it x number of times (once for each record in the table or query).

RESOLUTION

Surround each argument in the Dsum() function with quotation marks.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

The following example is based on the sample database Northwind.mdb (or NWIND.MDB in version 1.x or 2.0)

  1. Create a new form based on the Orders table and save it as MyTestForm.

  2. Add the following text boxes to the detail section of the form.

          Text Box:
    
             Name: Incorrect
             ControlSource: =DSum([Freight],"Orders")
          Text Box
             Name: Correct
             ControlSource: =DSum("[Freight]","Orders")
          Text Box
             Name: FreightField
             ControlSource: =[freight]
    
    

  3. View the form in Form view. The amount showing in the control "Incorrect" is the amount of the Freight field, multiplied by the total number of records in the Orders table. The amount in the "Correct" control is the correct sum of all the freight in the Orders table.

REFERENCES

For more information about the Dsum() function, search the Help Index for "Dsum."


Additional query words: expressions
Keywords : FmsHowto kbusage
Version : 1.0 1.1 2.0 7.0 97
Platform : WINDOWS
Hardware : X86
Issue type : kbprb
Resolution Type : Info_Provided


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 28, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.