Microsoft KB Archive/209605

= ACC2000: Incorrect Results Received with DSum Function =

Article ID: 209605

Article Last Modified on 12/12/2002

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q209605



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

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).



SYMPTOMS
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 do not receive an 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.



Steps to Reproduce Behavior
The following example is based on the sample database Northwind.mdb.  Create a new form based on the Orders table and save it as MyTestForm.  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]  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.

