Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum value of a control based on another

Status
Not open for further replies.

Brunn

Programmer
May 22, 2007
3
US
Hello - I've got a report, which is based on a union query, that gives me 7 months of data. The results look like this:
RptDate TI WI AA
12/11/07...12...12...24
11/11/07...15...14...17
10/11/07...10...6...19
9/11/07...2...20...3
8/11/07...13...14...15
7/11/07...12...12...23
12/11/06...23...5...23

What I need to do is sum up the past 6 months, and exclude the prior year data. I was able to write some code using the On Format property of the detail section to get the correct sum (essentially a bunch of if..then's), but I have many more controls to perform this on then what is listed above. I was hoping someone could provide some insight as to how to streamline this and get the needed result without having to write a ton of code for each control. I want the results of the report to look like this:

12/11/07 12 12 24
12/11/06 23 5 23
6 months 62 78 101

Thanks in advance.
Greg
 
You should be able to use expressions in control sources like:
[tt][blue]
=Sum(abs([RptDate]>= DateAdd("m",-6,Date())) * [TI])
[/blue][/tt]

Duane MS Access MVP
Now help me support United Cerebral Palsy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top