Full Version: Another running sum question
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
Luceze
Hi all,

I'm trying to create a DSUM running sum with multiple criteria. I can get single criteria to work but I'm having trouble adding additional criteria. Once I add the second piece it sums all of the data instead of grouping at any level.

Here is my SQL that doesnt work.
CODE
SELECT quPlan_Wages.lngSysID, quPlan_Wages.Amount, quPlan_Wages.lngYear, quPlan_Wages.lngMonth,
DSum("amount","quPlan_Wages","[lngMonth]<=" & [lngMonth] And "[lngSysID]=" & [lngSysID]) AS RunTot
FROM quPlan_Wages
GROUP BY quPlan_Wages.lngSysID, quPlan_Wages.Amount, quPlan_Wages.lngYear, quPlan_Wages.lngMonth;


Any suggestions?

Thanks,
pbaldy
Try

DSum("amount","quPlan_Wages","[lngMonth]<=" & [lngMonth] & " And [lngSysID]=" & [lngSysID])
Luceze
Thank you Paul. sad.gif I didn't realize that the AND operator needed to be within the quotes.
pbaldy
No problem. Basically the only things outside the quotes are those things being evaluated for their values (variables, form references, etc).
Luceze
Good to know.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.