473,385 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Count of unique values in a report footer

SJM
I have a report that displays records of real estate properties. It is
possible for each property to appear a number of times for various reasons.
Each record however is unique. What I would like to do is display the total
of the number of unique properties in the report footer, not just a count of
the number of records. I have experimented with grouping on the property
field and using running sums but to no avail. I have also tried to determine
the unique property count by using a recordset based on the query underlying
the report in the report footer on format event, but this would not work as
it complained of not having the required parameter which did not make sense.
Maybe I could save the underlying data to a table and base the report on
that and then get a recordcount on a recordset based on the table to fill in
the unique property count field in the report. Should it be an easy thing to
display a 'unique count' in a report footer?
Nov 13 '05 #1
2 7782
Ed
SJM:

Try this out for size. It assumes that you have a table or a query as the
record source for the report and that [PropertyID] is the unique identifier
of the property and that [PropertyID] is an output column of the record
source. Create a field named txtUniqueRecs in the report footer section,
then copy this code into the On Print event.

Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
On Error Resume Next
Dim rst As DAO.Recordset
Dim strRecSource As String
Dim strSQL As String
strRecSource = Me.RecordSource
strSQL = "SELECT DISTINCT PropertyID FROM (" & strRecSource & "); "
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.BOF And rst.EOF Then
'there's no data,
'return 0
Me!txtUniqueRecs = 0
Else
rst.MoveLast
Me!txtUniqueRecs = rst.RecordCount
End If
Set rst = Nothing
End Sub

Add whatever error routine you normally use.

Good luck,
Ed

"SJM" <no****@ms.com> wrote in message
news:Ny****************@nnrp1.ozemail.com.au...
I have a report that displays records of real estate properties. It is
possible for each property to appear a number of times for various reasons. Each record however is unique. What I would like to do is display the total of the number of unique properties in the report footer, not just a count of the number of records. I have experimented with grouping on the property
field and using running sums but to no avail. I have also tried to determine the unique property count by using a recordset based on the query underlying the report in the report footer on format event, but this would not work as it complained of not having the required parameter which did not make sense. Maybe I could save the underlying data to a table and base the report on
that and then get a recordcount on a recordset based on the table to fill in the unique property count field in the report. Should it be an easy thing to display a 'unique count' in a report footer?

Nov 13 '05 #2
SJM
Ed.
This is very similar to what I tried except...
A. I used ADODB instead of DAO.
B. I referenced the underlying report query rather than the report
recordsource.
I was wanting to do something based on RecordSetClone but this is not
available in reports, but using the report's recordsource in the sql like
you outline below could be the angle I am looking for. I haven't tried it
yet, but thanks anyway, I will give it a go.

"Ed" <ed*********@cox.net> wrote in message
news:Yu%dd.6666$EZ.6012@okepread07...
SJM:

Try this out for size. It assumes that you have a table or a query as the
record source for the report and that [PropertyID] is the unique identifier of the property and that [PropertyID] is an output column of the record
source. Create a field named txtUniqueRecs in the report footer section,
then copy this code into the On Print event.

Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
On Error Resume Next
Dim rst As DAO.Recordset
Dim strRecSource As String
Dim strSQL As String
strRecSource = Me.RecordSource
strSQL = "SELECT DISTINCT PropertyID FROM (" & strRecSource & "); "
Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
If rst.BOF And rst.EOF Then
'there's no data,
'return 0
Me!txtUniqueRecs = 0
Else
rst.MoveLast
Me!txtUniqueRecs = rst.RecordCount
End If
Set rst = Nothing
End Sub

Add whatever error routine you normally use.

Good luck,
Ed


Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: L Mehl | last post by:
Different users of the app will want or not want to see report footer ( appears as a separate page). I can make the section invisible with a DLookup of a Y or N value from a 'parameters' table ...
1
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...
1
by: Simon Matthews | last post by:
Hope someone can help an Access beginner! I've just started keeping my surgical logbook on access and it's a simple flat-file affair. I have created several queries that will list cases...
5
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to...
3
by: Rabun | last post by:
Heres one that is giving me fits ( = = Access newbie), more than likely something simple that I blew right over . . . any help is appreciated - I have a report based on a query, with several...
5
by: Soccer5 | last post by:
Trying to Count records on a report that meet a certain criteria. Have a text box in the Report Footer that has the following in the Control Source: =Count(="S") This does not work. It...
1
by: N06149 | last post by:
I have a report based on a query. I list an Org_Type then Org_Name then the Projects associated with it. Sample of report below: Community Type...
3
by: isoquin | last post by:
I've looked, and not found much. I have a text field in a form named , which acquires its data through a control source of =getLocation() the getLocation() function returns a DLookup, which...
1
newnewbie
by: newnewbie | last post by:
Hi, Could somebody please help me with VBA code to count unique values in a Report? Report is based on a query that has grouped values. Basically, I would like to use formula...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.