[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

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

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
SteveL13
Asked:
SteveL13
  • 2
3 Solutions
 
COACHMAN99Commented:
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
 
crystal (strive4peace) - Microsoft MVP, AccessRemote Training and ProgrammingCommented:
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
 
Gustav BrockCIOCommented:
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
 
COACHMAN99Commented:
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

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now