The DSUM() function has 3 parameters: expression, domain, [criteria]
The expression is the field in the domain you want to sum. This field name must be a string: "ItemQuantity"
The domain is the table/query you want to use to get the numbers. The domain name must be a string:"Table1"
The criteria is like a WHERE clause in a query, without the word WHERE. This must also be a string: "ItemName = 'skittles'"
Note the placement/usage of the quotes. Because the criteria value is a string, delimiters must be used.
I used single quotes, but you could use double quotes.
"ItemName = ""skittles"""
So on a form, set the control source of a text box control to
Code:
=DSum("ItemQuantity","Table1","ItemName = 'skittles'")
or
Code:
=DSum("ItemQuantity","Table1","ItemName = ""skittles""")
----------------------------------------------------------------------------
In a query, use
Code:
Qnty: DSum("ItemQuantity","Table1","ItemName = 'skittles'")
----------------------------------------------------------------------------
If the criteria field was a number type, you would use
Code:
=DSum("ItemQuantity","Table1","ItemFK = 10")
------------------------------------------------------------------------------
If you have spaces in field names, the field name must be enclosed by brackets AND quotes:
Code:
=DSum("[Item Quantity]","Table1","ItemName = 'skittles'")