Solved

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

Posted on 2016-11-21
4
28 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
  • 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 19

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 125 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 49

Accepted Solution

by:
Gustav Brock earned 250 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 125 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

743 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

13 Experts available now in Live!

Get 1:1 Help Now