[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How count records in each month from current month going back 12 months

Posted on 2016-11-21
4
Medium Priority
?
77 Views
Last Modified: 2016-11-22
I have a table that has a field for RecordID and a field for DateEntered.  And then I am going to have a form where the user will enter a date range, for example, 12/1/2015 through 11/30/2016 (two date fields to be entered).

And then I want to have a report that shows the record counts for each month.  Something like the attached report result.

But I don't know how to query the data and how to make the labels, (example: "December, 2015") get populated.

Any help much appreciated.
ReportExample.jpg
0
Comment
Question by:SteveL13
[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
4 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 41896643
Do you want to count the months for date entered? I.e. count all records entered in each month/year?
If yes try
SELECT Count(table1.id) AS CountOfid, Format([date entered],'mmm/yyyy') AS DateEntered
FROM table1
GROUP BY Format([date entered],'mmm/yyyy');
0
 
LVL 22

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 500 total points
ID: 41896704
These EE video tutorial explains how to setup a report and group by parts of a date.  

Create a Query and Grouped Report and Modify Design using Access
https://www.experts-exchange.com/videos/4514/Create-a-Query-and-Grouped-Report-and-Modify-Design-using-Access.html

Polish Reports in Access
https://www.experts-exchange.com/videos/4559/Polish-Reports-in-Access.html

Perhaps what you want to do is put the detail in the Detail section and set visible to No. Then show the totals that you really want to see in a group section.
0
 
LVL 52

Accepted Solution

by:
Gustav Brock earned 1000 total points
ID: 41897340
You can use a query like this:
PARAMETERS 
    [Forms]![DateSelect]![StartDate] DateTime, 
    [Forms]![DateSelect]![EndDate] DateTime;
SELECT 
    Format([DateEntered],"yyyy/mm") AS YearMonth, 
    Format([DateEntered],"mmmm"", ""yyyy") AS MonthLabel, 
    Count(*) AS RecordCount
FROM 
    DateItems
WHERE 
    DateItems.DateEntered Between [Forms]![DateSelect]![StartDate] And [Forms]![DateSelect]![EndDate]
GROUP BY Format([DateEntered],"yyyy/mm"), Format([DateEntered],"mmmm"", ""yyyy");

Open in new window

Then, in the report, sort on YearMonth.

See the attached demo.

/gustav
Report.accdb
0
 
LVL 7

Assisted Solution

by:COACHMAN99
COACHMAN99 earned 500 total points
ID: 41897796
Create a query as follows, then a report, designed on the query

SELECT Count(table1.id) AS CountOfid, Format([date entered],'mmm/yyyy') AS DateEntered
FROM table1
WHERE (((table1.[Date Entered])>=[Forms]![Form1]![FromDate]) AND ((table1.[Date Entered])<=[Forms]![Form1]![ToDate]))
GROUP BY Format([date entered],'mmm/yyyy')
ORDER BY Format([date entered],'mmm/yyyy');
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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 different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

650 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