?
Solved

DSum Multiple Conditions

Posted on 2005-02-24
6
Medium Priority
?
1,075 Views
Last Modified: 2008-01-16
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
Comment
Question by:JKubon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 

Author Comment

by:JKubon
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

by:JKubon
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 51

Accepted Solution

by:
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 51

Expert Comment

by:Gustav Brock
ID: 14763453
Did this work for you?

/gustav
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question