View Full Version : Problems with DSum


Kasper
03-21-2009, 05:39 AM
I really hope that someone can help me on this one. I am really frustrated over this... New to Access, and DSum.. but here goes.

I need to create a graph showing the accumulated time usage over the lifetime of a project. For this purpose I have created a query doing a running sum using DSum on the table WORK.

Initially, I would like the data to be presented in a table like this:

Bill_Code Work_Week_Ending Work_Hours RunSum
1 09-01-2009 30 30
1 16-01-2009 20 50
2 09-01-2009 10 10
2 16-01-2009 15 25

To create this table, I created the following query (in query builder):

RunSum: Format(DSum("Work_Hours";"[WORK]";"[Bill_Code] = " & [WORK].[Bill_Code] & " AND Work_Week_Ending <= #" & [Work_Week_Ending] &"#"#);"Standard")

Unfortunately, the result generated does not provide the hoped for result for RunSum, as the grand total (i.e. for bill_code 1 the total is 80) is shown for Work_week_ending 09-01-2009. the next couple of dates then seem to sum up nicely (as they are supposed to). When the month changes, the query then presents the total again.

Can anyone help me to generate the correct result?
Thanks

Guus2005
03-24-2009, 07:24 AM
You have to show the complete query and better: a sample database.

Most of the time it is possible to avoid using DSUM in a query. It is better to use a subquery. They are easier to debug.

Enjoy!