DSum Function (SQL Only)

See AlsovbfctDSumSee                 ExamplevbfctDSumEx>Low

Description

Returns the sum of a set of values in a specified set of records (domainCQNETL).

Syntax

DSum( expr, domain [, criteria] )

Remarks

The DSum function uses the following arguments.

Argument        Description

 

expr                 String expression1330R89 identifying the field that contains the numeric data you want to add, or an expression that performs calculations using the data in that field.  Operands in expr can include the name of a table field, or a Visual Basic function (which can be intrinsic but not a user-defined function or one of the other domain aggregate or SQL aggregate functions).

domain             String expression identifying the records that constitute the domain.  It can be a table name, a query name, or an SQL expression that returns data.

criteria              Optional string expression used to restrict the range of data on which DSum is performed.  For example, criteria could be the WHERE clause in an SQL expression (without the word WHERE).  If criteria is omitted, DSum evaluates expr against the entire domain.

 

Unlike DCount, which returns the number of records, DSum totals the values in a field.  For example, you could use DSum to determine the total cost of freight charges.

If the criteria argument contains non-numeric text other than field names, you must enclose the text in single quotation marks.  In the following example from an Orders table, Ship Country is the name of a field, and UK is a string literal.

X = DSum("[Freight]", "Orders", "[Ship Country] = 'UK'")

Y = DSum("[Freight]", "Orders", "[Ship Via] = 1")