Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

missing operator error 1

Status
Not open for further replies.

burnside

Technical User
Dec 4, 2004
236
GB
why do i get this error-

syntax error(missing operator)in query exprssion
'DSum ([lots].price sold)'

in this sql

SELECT customers.cusID, customers.[customer name], customers.cash, customers.cheque, customers.switch, customers.card, DSum([lots].price sold) AS lottot
FROM customers INNER JOIN lots ON customers.cusID = lots.cusID
WHERE (((customers.cusID)=[forms]![purchinvselect]![purchname]));
 
The format for DSum is
Code:
DSum(expr, domain, [criteria])
You have not specified the domain (i.e. Table Name) in your use of DSum.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
price sold--> [price sold]?

Pampers [afro]
Just let it go...
 
A wild guess

DSum("[price sold]", "lots", "lots.cusID=" & [forms]![purchinvselect]![purchname])
 
many thanks
used this
DSum("[price sold]","lots") AS lottot
 
errr.... this sql is totalling All lots.price sold in the table and i dont know why

SELECT customers.cusID, customers.[customer name], customers.cash, customers.cheque, customers.switch, customers.card, DSum("[price sold]","lots") AS lottot
FROM customers INNER JOIN lots ON customers.cusID = lots.cusID
WHERE (((customers.cusID)=[forms]![purchinvselect]![purchname]));
 
You haven't supplied any criteria for the DSum. Look at JerryKlmns's post.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
thanks - but wht do i need that as well as the WHERE
part on the sql

cheers MG
 
Because the DSum command is executed independently of the rest of the SQL statement. It is just a function that returns a value based on its calling arguments and doesn't know anything else about the context from which it was called.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Why using the slow DSum function ?
Doesn't this meet your requirment ?
SELECT C.cusID, C.[customer name], C.cash, C.cheque, C.switch, C.card, Sum(L.[price sold]) AS lottot
FROM customers AS C INNER JOIN lots AS L ON C.cusID = L.cusID
WHERE C.cusID = [Forms]![purchinvselect]![purchname]
GROUP BY C.cusID, C.[customer name], C.cash, C.cheque, C.switch, C.card

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top