Hi,
I know there are several posts already on cummulative totals, but I am quite new to Access so am having trouble relating them to my project so thought I would start my own.
Basically, I have a database containing information on several projects, for each project there are two lots of weekly data, projected hours and actual hours. I need to be able to produce charts of the cumulative totals of these values either for individual projects or totalled across several projects.
I currently have the following SQL in a query which produces the cumulative totals by week and project.
However I would like to modify it so that by default it calculates the cumulative weekly totals across all projects and then I can limit the projects for which it does this via code. I have a form with a list box and basically when the user clicks the [Generate Totals] button I want it to use the ID of the project(s) selected to limit the query.
I have tried simply removing the [ProjectID] = a.ProjectID line from the SQL to try and stop it sorting them by project ID but this does not work. If anyone could show me how to modify this it would be appreciated.
Also. It is likely that when the database if fully populated there will be a lot of records and I have read that using queries a subqueries to generate the totals in very inefficient and that it would be much better to do this all in code. I really don't know how to do this, so if anyone could help with how to put the code together it would really help.
Thanks
Robyn
I know there are several posts already on cummulative totals, but I am quite new to Access so am having trouble relating them to my project so thought I would start my own.
Basically, I have a database containing information on several projects, for each project there are two lots of weekly data, projected hours and actual hours. I need to be able to produce charts of the cumulative totals of these values either for individual projects or totalled across several projects.
I currently have the following SQL in a query which produces the cumulative totals by week and project.
Code:
SELECT a.Week, a.ProjectID,
(Select Sum(ProjectedHours) from [qryPandAByWeekAndProject]
where [ProjectID] = a.ProjectID
and [Week] <= a.Week) AS Predicted,
(Select Sum(WeeklyTabs) from [qryPandAByWeekAndProject]
where [ProjectID] = a.ProjectID
and [Week] <= a.Week) AS Actual
FROM qryPandAByWeekAndProject AS a
ORDER BY a.ProjectID, a.Week;
However I would like to modify it so that by default it calculates the cumulative weekly totals across all projects and then I can limit the projects for which it does this via code. I have a form with a list box and basically when the user clicks the [Generate Totals] button I want it to use the ID of the project(s) selected to limit the query.
I have tried simply removing the [ProjectID] = a.ProjectID line from the SQL to try and stop it sorting them by project ID but this does not work. If anyone could show me how to modify this it would be appreciated.
Also. It is likely that when the database if fully populated there will be a lot of records and I have read that using queries a subqueries to generate the totals in very inefficient and that it would be much better to do this all in code. I really don't know how to do this, so if anyone could help with how to put the code together it would really help.
Thanks
Robyn