Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

count where clause in Access Report

Posted on 2016-08-09
5
Medium Priority
?
66 Views
Last Modified: 2016-08-12
I would like to count all the records by status in group field in an Access Report.

I have the report built and a grouping set and I can count the records according to the grouping (Location)

Now I would like to do a count of the records by location and by status so I can show the following:

Oklahoma  200  /   In Progress   150   /    Scheduled    25    /      On Hold  20      /     Canceled    5

Texas          100  /   In Progress   50   /    Scheduled    25    /      On Hold  20      /     Canceled    5


I would like to count records according to P_Status  where P_Status equals 'In Progress'

and I would like to count records according to P_Status  where P_Status equals 'Scheduled'

some I am thinking something like the following

=count (all records) where P_Status = In Progress

and

=count (all records) where P_Status = Scheduled

...novice here so please be specific
0
Comment
Question by:ssblue
[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
  • 3
5 Comments
 
LVL 25

Accepted Solution

by:
chaau earned 1000 total points
ID: 41749559
I suggest you built a CROSS TAB report instead. Run the wizard - you will be surprised how simple it is
1
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 41750701
There is a lot of info missing here...
What does your source data look like?
Is what you posted the "exact" output you are looking for?
...or do you want that format to appear appended somewhere on your existing report?
You did not post a screenshot of your existing report or layout.

In any event...
I will presume that you need this summary at the "end" of the report (Report Footer)
...then you have to hardcode each State and Status into each textbox
Something like this:
=DCount("Status","YourTable","Status='In Progress'" & " AND " & "State='Oklahoma'")

Sample and screenshot attached
summaryDatabase175.mdb
1
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 1000 total points
ID: 41750817
I am sure you can follow the syntax logic and apply it to the other "Status" values.

Again, the kicker here is that, for a Report Summary, all the discrete values must be hardcoded.
Meaning you will have to type (into each textbox controlsource) each state name and status.

;-)

Jeff
1
 
LVL 39

Expert Comment

by:PatHartman
ID: 41750844
Rather than hard-coding the discrete values (which is always problematic), use the crosstab approach suggested by chaau but embed it as a subform in the report footer section so it appears at the end of the report.
1
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 41751057
Yes, ...First please give the crosstab technique a shot.

When I first read the question:
1. ...I presumed, (perhaps wrongly so), that you may have only had a few discreet values.
2. I also thought that what you posted as a result, was the exact format you were after.
3. I also presumed that this would be in the report footer, ...and as controls, ...it would be easier to manipulate them in a way that might not be possible (easily) with a crosstab.

So, yes, give the crosstab a shot, ..it may not give you the "exact" output you need, ...with no maintenance required.

;-)

Jeff
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

721 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