DSUM error# Syntax problem?

P

Phil Smith

I am trying to use DSUM to create a running total via Method 1 in MS TID
290136.

I am getting an error in my DSUM statement. Very simple query:

SELECT SalesForGraph.Week AS CWeek, SalesForGraph.[2006Profit],
DSum("2006Profit","SalesForGraph","[WEEK] <= " & [Cweek]) AS RunTot
FROM SalesForGraph
ORDER BY SalesForGraph.Week;

The string for Criteria resolves to:
[week] <=1
[week] <=2

etc. What am I doing wrong?

Phil
 
O

Ofer Cohen

Mybe,

If the WEEk field type is text, then try

SELECT SalesForGraph.Week AS CWeek, SalesForGraph.[2006Profit],
DSum("2006Profit","SalesForGraph","Val([WEEK]) <= " & Val([Cweek])) AS RunTot
FROM SalesForGraph
ORDER BY SalesForGraph.Week;
 
P

Phil Smith

Changed it to

SELECT SalesForGraph.Week AS CWeek, SalesForGraph.[2006Profit],
DSum("2006Profit","SalesForGraph","Val([WEEK]) <= " & Val([Cweek]) & "
") AS RunTot
FROM SalesForGraph
ORDER BY SalesForGraph.Week;


Still errors out.

Phil
 
P

Phil Smith

More weirdness:

If I click on one of the error# cells in datasheet view, I get a dialog
box that says:
Syntax error (missing operator) in query expression Sum(2006Profit)

This error does not show up when the query is run.
 
D

Duane Hookom

Don't use CWeek in the DSum(). Try:

SELECT SalesForGraph.Week AS CWeek, SalesForGraph.[2006Profit],
DSum("2006Profit","SalesForGraph","[WEEK] <= " & [week]) AS RunTot
FROM SalesForGraph
ORDER BY SalesForGraph.Week;

--
Duane Hookom
Microsoft Access MVP


Phil Smith said:
More weirdness:

If I click on one of the error# cells in datasheet view, I get a dialog
box that says:
Syntax error (missing operator) in query expression Sum(2006Profit)

This error does not show up when the query is run.








Phil said:
Changed it to

SELECT SalesForGraph.Week AS CWeek, SalesForGraph.[2006Profit],
DSum("2006Profit","SalesForGraph","Val([WEEK]) <= " & Val([Cweek]) & "
") AS RunTot
FROM SalesForGraph
ORDER BY SalesForGraph.Week;


Still errors out.

Phil
 

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

Similar Threads


Top