473,566 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7809
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_Pr int(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.OpenR ecordset(strSQL , dbOpenSnapshot)
If rst.BOF And rst.EOF Then
'there's no data,
'return 0
Me!txtUniqueRec s = 0
Else
rst.MoveLast
Me!txtUniqueRec s = rst.RecordCount
End If
Set rst = Nothing
End Sub

Add whatever error routine you normally use.

Good luck,
Ed

"SJM" <no****@ms.co m> 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*********@co x.net> wrote in message
news:Yu%dd.6666 $EZ.6012@okepre ad07...
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_Pr int(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.OpenR ecordset(strSQL , dbOpenSnapshot)
If rst.BOF And rst.EOF Then
'there's no data,
'return 0
Me!txtUniqueRec s = 0
Else
rst.MoveLast
Me!txtUniqueRec s = 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
4523
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 Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer) Reports!rptValuationDetail.Section(acFooter).Visible = _ DLookup("",...
1
3557
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,...
1
1535
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 performed at different hospitals and reports based on the queries to print out the relavent details. What I would like to do is have a summary sheet in...
5
18246
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 display the number of times a certain value appears in a certain field (i.e. perform a ‘count'). I will be doing this for many values in many...
3
1974
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 columns I need to work with. Values in the cols are " Over " and " Under", as text values. The query is for a start / end date, my count of records...
5
10848
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 counts ALL records whether Record Type = "S" or "M" There is nothing unique about the records to distinguish S-type records from the M-type records.
1
1882
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 ---------------------------------------------------------Org_Type Header Org_Name bla bla bla project a project b project c...
3
3216
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 changes based on some other field of that record. Now, I would like the form footer to count the two different locations that may occur. So, naturally...
1
3697
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 =COUNTUNIQUEVALUES() in the report form. Is it possible? Thank you! Lena
0
7666
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...
0
7584
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...
1
7644
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...
0
7951
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...
1
5484
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...
0
5213
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...
0
3643
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.