Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
Solved

# DSum Multiple Conditions

Posted on 2005-02-24
Medium Priority
1,085 Views
USING MICROSOFT ACCESSXP

I have a control on a report looking up the total of hours for the month from the time table.  I cannot add this table/query of the table into the main underlying query of the report because there wouldn't be a valid join.

I need the sum of the Hours between to two dates.  The dates are parameters of the report.

My DSum works if I use one condition but I'm have #Error messages in the control for multiple conditions or if I use the between statement.

FIRST DATE
[Enter Ending Month Date for WIP Period]
e.g., 01/31/05

SECOND DATE
[Enter Ending Date for Prior Month]
e.g., 12/31/04

I want the range that is >[Enter Ending Date for Prior Month] and <=[Enter Ending Month Date for WIP Period]

The only formula I have working at present is:
=DSum("[HoursWorked]","Time Billed","[WorkDate]<=[Enter Ending Month Date for WIP Period]")

The other formulas I'm working on that do not work are:
=DSum("[HoursWorked]","Time Billed","[WorkDate]>[Enter Ending Date for Prior Month] And [WorkDate]<=[Enter Ending Month Date for WIP Period]")
=DSum("[HoursWorked]","Time Billed","[WorkDate] Between ([Enter Ending Date for Prior Month]+1) And [Enter Ending Month Date for WIP Period]")

I have even tried the work around based on three controls.  One that would calculate the grand total through [Enter Ending Month Date for WIP Period] and then one calculating through [Enter Ending Date for Prior Month] separately.  The difference between these two calculations would yield the result I need.  HOWEVER...the DSum expression for the prior period isn't working either.

=DSum("[HoursWorked]","Time Billed","[WorkDate]<=[Enter Ending Date for Prior Month]")

Going to continue to play with the expressions.  I would pressume this ought to be able to work in a single DSum, but if it takes three controls ... fine by me.  I'm interested in the results however I get there.

Thanks!
Joseph

0
Question by:JKubon
• 2
• 2

Author Comment

ID: 13398608
These items are in the Report Footer section.

Once I put a control in the header for the SECOND DATE prompt, the individual formulas worked.  The FIRST DATE prompt already had a reference in the header of the report.

Right now I'm getting accurate results using the 3 separate field method.  Will be testing the multiple conditions now.

0

Author Comment

ID: 13398731
With the multiple conditions...

This produces expected results:
DSum("[HoursWorked]","Time Billed","[WorkDate]>[Enter Ending Date for Prior Month] And [WorkDate]<=[Enter Ending Month Date for WIP Period]")

This produces results but the amount is wrong:
=DSum("[HoursWorked]","Time Billed","[WorkDate] Between ([Enter Ending Date for Prior Month]+1) And [Enter Ending Month Date for WIP Period]")

0

LVL 52

Accepted Solution

Gustav Brock earned 1000 total points
ID: 13403684
You might try this as your input are strings:

=DSum("[HoursWorked]","Time Billed","[WorkDate]>DateValue([Enter Ending Date for Prior Month]) And [WorkDate]<=DateValue([Enter Ending Month Date for WIP Period])")

/gustav
0

LVL 52

Expert Comment

ID: 14763453
Did this work for you?

/gustav
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
###### Suggested Courses
Course of the Month15 days, 12 hours left to enroll