Counting Records by Status but NOT printing all records

ChrisCione

Board Regular
Joined
Aug 27, 2008
Messages
92
Office Version
  1. 365
Platform
  1. Windows
All records in my mdb are assigned 1 of 3 statuses: Pending, Active or Closed.


In the header of one of my main reports, I have 3 unbound textboxes to display the count of records for each status. For example, =Sum(IIf([RecruitmentStatus]="Closed",1,0)) and so on.


Here's what I am trying to accomplish:


While I want to show the count of records for EACH status (Pending, Active or Closed), I do NOT want to print any of the records in a Closed status.


In the query (the record source for the report), I unchecked "Show" for the Closed status, but it then will not count any of the closed records. I tried changing the report record source to the table, but I get the same results. If I filter out the Closed records, then it will not count.


I've spent a considerable amount of time Googling and have tried On Load and On Open Filters - all to no avail.


Is my ask possible?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
The "Don't Show" check box is just for fields (columns), not records (rows).

One option is to do two queries:
1. A Totals Query that returns the counts for each Status
2. A Select Query that returns all the records you want to print (filter out closed).

Then, create a Report for each, and put them on the same Report as Subreports.
 
Upvote 0
You are welcome.
If you need any info on Subreports, just Google it, and there is lots of good information, tutorials and videos out there.
Using Subreports are a great way to get data from two separate data sources on the same Report.
 
Upvote 0
Another way (Only works in the Print Preview view or when printing) is to hide the detail section on the Format event.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Detail.Visible = True  'I find it best to ensure that you set it to visible first
If Status = "Closed" Then Me.Detail.Visible = False
End Sub
The totals can then be calculated as a standard expression in the report footer:

Code:
=Sum(IIf([Status]="Active",1,0))
=Sum(IIf([Status]="Pending",1,0))
=Sum(IIf([Status]="Closed",1,0))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,411
Messages
6,119,346
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top