Solved

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

Posted on 2016-11-21
4
58 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 20

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 50

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

737 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