Solved

Report to display Current Month Data and Previous X Month's data.

Posted on 2006-07-24
3
249 Views
Last Modified: 2011-10-03
I am building some reports of data that is entered each month.  I need to generate reports that contain the data for this month as well as the previous X months.  I am having trouble with building the subtraction of these dates.  I have a form with 3 dropdown menus.  One for month (Jan, Feb, ...) one for Year (00, 01, 02,...), and one for Number of months (1, 2, ...).

How can I build a query off this so that when I select Feb 06 and previous 4 months a query gives me reports for:
Feb06
Jan06
Dec05
Nov05  

Is there a way to subtract dates?

Thanks!
0
Comment
Question by:busbeead
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 17167921
You can make use of DateAdd

e.g
dateadd("m",-4,currdate)

"m" = months
-4 = back 4
currdate = based from this date

Now in your query, for your selected date that u want t check against, u can do a between
e.g.

where somedatefield between mydate and dateadd("m",-4,mydate)
0
 

Author Comment

by:busbeead
ID: 17168617
That is exactly what I was looking for.  I had been trying to build all these stupid tables to figure this out.  Thanks so much for such a quick solution!
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17170449
No probs!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

932 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now