I can't get Dsum to work

R

Robert_DubYa

I am using the following statement but I'm getting a total for the entire
data set were I only want a total of "Qty Due Next Week" for each "Part".

DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = " & '[Part]')

any help is appreciated. I would also be deeply inbebted if you could
provide the reason why.

thanks!
Robert
 
A

Al Campagna

Robert,
Is Part a text field?
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = ' " & [Part] & " ' ")
(remove the spaces between the dbl and single quotes... I expanded them for
clarity)
--
hth
Al Campagna
Microsoft Access MVP
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."
 
B

BruceM

If Part at the very end of the expression is a text field, you need to
rearrange the quotes:
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = '" & [Part] & "'")
or
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = """ & [Part] & """")

Expanded for clarity, that's:
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = ' " & [Part] & " ' ")
or
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = " " " & [Part] & " "
" ")

If Part is a number field:
DSum("[Qty Due Next Week]","qryInvMovement1","[Part] = " & [Part])

All of this assumes that the second Part (at the end of the expression) is a
field in the record source of the form in which the code is contained, or
maybe an unbound control into which the user has typed a value. The intent
of the last part of DSum is "records in which [Part] matches the value in
[Part] on the form" or something along that idea.
 

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