Cumulative total problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to add a cumulative total column into an existing query. Every
time I try to run the query below Access shuts down. Is there a problem with
the expression I am using?
SELECT[qry York Data -- PTD].Period, [qry York Data -- PTD].Month, [qry York
Data -- PTD].[PTD VC Strategic], (SELECT Sum([PTD VC Strategic]) FROM [qry
York Data -- PTD] AS [Self] WHERE [Self].[Period] <= [qry York Data --
PTD].[Period]) AS CumulativeTotal
FROM [qry York Data -- PTD];
 
Rob said:
I am trying to add a cumulative total column into an existing query. Every
time I try to run the query below Access shuts down. Is there a problem
with
the expression I am using?
SELECT[qry York Data -- PTD].Period, [qry York Data -- PTD].Month, [qry
York
Data -- PTD].[PTD VC Strategic], (SELECT Sum([PTD VC Strategic]) FROM
[qry
York Data -- PTD] AS [Self] WHERE [Self].[Period] <= [qry York Data --
PTD].[Period]) AS CumulativeTotal
FROM [qry York Data -- PTD];
try

SELECT
q.Period,
q.[Month],
q.[PTD VC Strategic],
(SELECT
Sum(S.[PTD VC Strategic])
FROM
[qry York Data -- PTD] AS S
WHERE
S.[Period] <= q.[Period]) AS CumulativeTotal
FROM
[qry York Data -- PTD] As q;

If the above works, may I suggest that
you reevaluate your naming strategy.

"Month" is an Access reserved word.

109312 'Reserved Words in Microsoft Access'
http://support.microsoft.com/default.aspx?scid=kb;EN-US;109312

209187 'ACC2000: 'Reserved Words in Microsoft Access'
http://support.microsoft.com/default.aspx?scid=kb;EN-US;209187

286335 'ACC2002: Reserved Words in Microsoft Access'
http://support.microsoft.com/default.aspx?scid=kb;EN-US;286335

'What are reserved Access, ODBC and SQL Server keywords? '
http://sqlserver2000.databases.aspfaq.com/what-are-reserved-access-odbc-and-sql-server-keywords.html

The only punctuation I use in an object name
is the underscore....

826763 'Special characters that you must avoid
when you work with Access databases'
http://support.microsoft.com/default.aspx?scid=kb;EN-US;826763

Spaces cause you to need to put brackets
around the name -- that will bite you one
day when you need to use the name in
a subquery for the FROM clause...

Is

qryYorkData_PTD

really any less readable than

[qry York Data -- PTD] ?

or

PTD_VC_Strategic

vs

[PTD VC Strategic] ?
 

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


Back
Top