DSUM question

M

Martin

Normally,
DSum("UnitPrice", "Order Details", "OrderID = 10248")
but I want two or more criteria :

DSum("UnitPrice", "Order Details", "OrderID = 10248 AND ORDERID2=112233")

but it failed.

HOW TO MAKE IT TWO CRITERIA?

Thanks!
 
G

Guest

Hi Martin,

Your compound criteria is correct as long as ORDERID and ORDERID2 are
numeric. In fact, I just verified this by adding a numeric ORDERID2 field to
the Northwind Order Details table, adding the value 112233 to two of the
three records for ORDERID = 10248, and then adding your DSum statement to the
control source of a textbox on a form.

If ORDERID is numeric datatype and ORDERID2 is a text datatype, then use
this instead:

DSum("UnitPrice", "Order Details", "OrderID = 10248 AND ORDERID2='112233'")


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

:

Normally,
DSum("UnitPrice", "Order Details", "OrderID = 10248")
but I want two or more criteria :

DSum("UnitPrice", "Order Details", "OrderID = 10248 AND ORDERID2=112233")

but it failed.

HOW TO MAKE IT TWO CRITERIA?

Thanks!
 
G

Graham Mandeno

Hi Martin

Do you mean you want the sum of UnitPrice fields for both orders, OrderID
10248 AND OrderID 112233? What you need is not AND, but OR.

Try this:
DSum("UnitPrice", "Order Details", "OrderID=10248 or OrderID=112233")

or this:
DSum("UnitPrice", "Order Details", "OrderID in (10248, 112233)")
 
M

Martin

Thank you
Graham Mandeno said:
Hi Martin

Do you mean you want the sum of UnitPrice fields for both orders, OrderID
10248 AND OrderID 112233? What you need is not AND, but OR.

Try this:
DSum("UnitPrice", "Order Details", "OrderID=10248 or OrderID=112233")

or this:
DSum("UnitPrice", "Order Details", "OrderID in (10248, 112233)")
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Martin said:
Normally,
DSum("UnitPrice", "Order Details", "OrderID = 10248")
but I want two or more criteria :

DSum("UnitPrice", "Order Details", "OrderID = 10248 AND ORDERID2=112233")

but it failed.

HOW TO MAKE IT TWO CRITERIA?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top