473,799 Members | 3,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display DISTINCT Count on Report Header

77 New Member
Hi,

Please help with this problem.

I have a report that displays a list of Case/Judge Records.
using the following fields,

Case Nbr, Case Seq Nbr, Judge Name, Attorney name

723187, 1 , Judge1 , Att1
723187, 2 , Judge1 , Att2
237484, 2 . Judge2 , Att1
237484, 3 , Judge3 ,Att3
756565, 1 , Judge3 ,Att4

The list is grouped first by the Judge Name and secondly by Attorney Name.
It has a page break by the Judge Name, records start on a new page on Attoeny Name change.

I need to display the distinct count of Case Nbr per Judge, here are the things I tried that did not work,

1) I made a textbox on judgeheader section, named it txtuniquerecs and the format event of judgeheader had the following code. This code is always returning 1 for every judge.

Private Sub GroupHeader0_Fo rmat(Cancel As Integer, FormatCount As Integer)
On Error Resume Next
Dim rst As DAO.Recordset
Dim strRecSource As String
Dim strSQL As String

strRecSource = Me.RecordSource
strSQL = "SELECT COUNT(*) FROM (SELECT DISTINCT casenbr FROM (" & strRecSource & ")); "
Set rst = CurrentDb.OpenR ecordset(strSQL , dbOpenDynaset)

If rst.BOF And rst.EOF Then
Me!txtUniquerec s = 0
Else
rst.MoveLast
End If
Me!txtUniquerec s = rst.recordcount
rst.Close
Set rst = Nothing
End Sub


2) Created a textbox named txtcasecnt with controlsource as =1 and runnigsum as 'Over All'. In the textbox in judgefooter section controlsource was set to =[txtcasecnt]. This was giving the count per judge but not distinct count.

Please help as this is so urgent.

Thanks a lot in advance
Dec 10 '07 #1
7 6273
ADezii
8,834 Recognized Expert Expert
Hi,

Please help with this problem.

I have a report that displays a list of Case/Judge Records.
using the following fields,

Case Nbr, Case Seq Nbr, Judge Name, Attorney name

723187, 1 , Judge1 , Att1
723187, 2 , Judge1 , Att2
237484, 2 . Judge2 , Att1
237484, 3 , Judge3 ,Att3
756565, 1 , Judge3 ,Att4

The list is grouped first by the Judge Name and secondly by Attorney Name.
It has a page break by the Judge Name, records start on a new page on Attoeny Name change.

I need to display the distinct count of Case Nbr per Judge, here are the things I tried that did not work,

1) I made a textbox on judgeheader section, named it txtuniquerecs and the format event of judgeheader had the following code. This code is always returning 1 for every judge.

Private Sub GroupHeader0_Fo rmat(Cancel As Integer, FormatCount As Integer)
On Error Resume Next
Dim rst As DAO.Recordset
Dim strRecSource As String
Dim strSQL As String

strRecSource = Me.RecordSource
strSQL = "SELECT COUNT(*) FROM (SELECT DISTINCT casenbr FROM (" & strRecSource & ")); "
Set rst = CurrentDb.OpenR ecordset(strSQL , dbOpenDynaset)

If rst.BOF And rst.EOF Then
Me!txtUniquerec s = 0
Else
rst.MoveLast
End If
Me!txtUniquerec s = rst.recordcount
rst.Close
Set rst = Nothing
End Sub


2) Created a textbox named txtcasecnt with controlsource as =1 and runnigsum as 'Over All'. In the textbox in judgefooter section controlsource was set to =[txtcasecnt]. This was giving the count per judge but not distinct count.

Please help as this is so urgent.

Thanks a lot in advance
  1. Create a simple Query that returns the Unique (Distinct) combinations of Case Numbers (Case Nbr) and Judge Names and call it qryCases.
    Expand|Select|Wrap|Line Numbers
    1. SELECT DISTINCT <Your Table Name>.[Case Nbr], <Your Table Name>.[Judge Name] FROM <Your Table Name>;
  2. Place an Unbound Text Box in the Judge Name Header Section.
  3. Set its Control Source to:
    Expand|Select|Wrap|Line Numbers
    1. =DCount("*","qryCases","[Judge Name]='" & [Judge Name] & "'")
  4. I'm sure the SQL Gurus will come up with a better solution, but for now, this approach will work.
Dec 10 '07 #2
AccessHunter
77 New Member
Thanks a lot, it worked.

Can I ask another favour please.

Your suggestion helped me to display the distinct number of case nbr records on the header..Thanks a ton for that.
Now the new requirement is to display those unique numbers per Judge on a summary page as the last page in the report. Is it possible to do that? Please advice.

Thanks
Dec 10 '07 #3
ADezii
8,834 Recognized Expert Expert
Thanks a lot, it worked.

Can I ask another favour please.

Your suggestion helped me to display the distinct number of case nbr records on the header..Thanks a ton for that.
Now the new requirement is to display those unique numbers per Judge on a summary page as the last page in the report. Is it possible to do that? Please advice.

Thanks
  1. Create a New Report and set its Record Source = qryCases.
  2. Embed this Report as a Sub-Report into the Report's Footer.
  3. Do not attempt to Bind this Sub-Report to main Report, it is independent.
  4. Now, on the last page of the Report, (Report Footer), the Sub-Report will appear.
Dec 10 '07 #4
AccessHunter
77 New Member
Thanks for the immediate reply.

Actually What I wanted to do was to display the Unique count of Cases for each Judge on the summary page. When I tried the way you had explained, that displayed all the case number and judges like what I have in my qrycases.

Please help. Sorry if I am asking too much.
Dec 10 '07 #5
ADezii
8,834 Recognized Expert Expert
Thanks for the immediate reply.

Actually What I wanted to do was to display the Unique count of Cases for each Judge on the summary page. When I tried the way you had explained, that displayed all the case number and judges like what I have in my qrycases.

Please help. Sorry if I am asking too much.
Set the Record Source of your Sub-Report to the following Query which in itself is based on qryCases.
Expand|Select|Wrap|Line Numbers
  1. SELECT qryCases.[Judge Name], Count(qryCases.[Case Nbr]) AS [Unique_Case_Count]
  2. FROM qryCases
  3. GROUP BY qryCases.[Judge Name];
Dec 10 '07 #6
AccessHunter
77 New Member
Thank you soooo much for helping me with the issues. You rock...
Thanks again.
Dec 11 '07 #7
ADezii
8,834 Recognized Expert Expert
Thank you soooo much for helping me with the issues. You rock...
Thanks again.
You are quite welcome.
Dec 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
5683
by: Yasin | last post by:
Hi I have one reports which shows the Account wise daily transaction during the day.(pl's find below report layout format with column description) May or may not be each account have multiple transaction during the day. My report break and compute as shown below.
1
3566
by: Steve Heath | last post by:
I have a query that provides detail for sales transactions meeting certain criteria (date, purchase type, etc.) I am creating a report based on that query, and I want to add a summary section. I want to add some counts, such as the number of unique customers that purchased. I know can do this by running a new query to group by customerID, then doing another query against that to count the records, but there has to be a better way. Can I...
1
1882
by: seeker52 | last post by:
I receive an error 3464 when I put =count(*) in the controlsource of a textbox on the report header. The error is thrown at the filter created for the report when I docmd openreport. The error is not thrown if the =count(*) is not used. I want the textbox in the header of the report to show the number of records in the report. seeker53
4
3299
by: dixie | last post by:
I have a report which has records of students in various courses. It would normally show say 400 entries for 80 students doing an average of 5 courses each. I want to say on the report how many different students there are. Normally, I'd just use "No. Students = " & Count() , but this just gives me 400 - how do I do a count of Distinct Surnames on a report? dixie
17
16386
by: keith | last post by:
I am trying to get a exact count of different distinct entries in an Access column. At first, I was trying to work with three columns, but I've narrowed it down to one to simplify it. I've searched Google Groups for Distinct Count and Count, the Microsoft Help file (which apparently has bad links in Office 2003), and looked at other files, but I can't find the answer. The closest I've been able to get is to create a query to find the...
1
14494
by: nfrodsham | last post by:
In Microsoft's help literature, it states: "You can filter out non-unique rows by using the DISTINCT option of an aggregate function" I am trying to do this in Access 2003 with the COUNT aggregate function, but there is no reference, at least that I can find anywhere, of how to do this. I have multiple lines fields for which I would like to do a "count distinct", but for simplicity, I am showing an example of only one field. Here is...
1
3132
by: Beowulf | last post by:
I'm having some difficulty and I can't for the life of me figure out why. I have a main report, rptMain, that contains a report header (displays the AppTitle), 3 group headers (one is a header for the "report version" and is being used for a cover sheet, one is a category header, and the other is an item header), about 6 subreports in the Details section, 2 non-empty group footers, a page footer and a report footer. The 6 subreports in...
1
1674
by: Dave | last post by:
Hi all, I'm new to Reports, so please bear with me. I have a query that produces a list of participants by project. It also produces a list of files by project (participants and files are both many-to-many joins with project): _Project_ _Participants_ _Files_ Project1 participant1 file1
7
4655
by: CampbellJD1 | last post by:
I am using Access 2003 Professional. I have been working with Access for some time and I have created an MDB with a Linked Table and the Data there is temporarily transferred to other Table for different reports. I now have the task of a Daily report which I have been able to get to the point where it does 90% of what I need. I have been searching Google and Answer for the last three days on getting Access to do a Distinct Record Count in a...
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.