A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Counting unique values in a report



 
 
Thread Tools Display Modes
  #1  
Old November 30th, 2004, 02:55 PM
Tim Long
external usenet poster
 
Posts: n/a
Default Counting unique values in a report

Hello, I want to have a text box in my report header displaying the number of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple result
"10"?

Many thanks in advance

Tim Long


  #2  
Old November 30th, 2004, 03:17 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long



  #3  
Old November 30th, 2004, 04:11 PM
Tim Long
external usenet poster
 
Posts: n/a
Default

I'm learning! Many thanks for taking the time and trouble to explain.

Tim Long

"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




  #4  
Old August 20th, 2005, 10:35 PM
imad hammad
external usenet poster
 
Posts: n/a
Default

I have read this suggestion in a different post as well and i still can't get
it to work.

When I set the control source, for my text box in the reports footer, to
[txtCustomerCount] (or any text box for that matter) i get a "No such Field
in the Field List" error. Please help thank you.

"Tim Long" wrote:

I'm learning! Many thanks for taking the time and trouble to explain.

Tim Long

"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




  #5  
Old August 21st, 2005, 03:35 PM
RoyVidar
external usenet poster
 
Posts: n/a
Default

Did you just forget the equal sign when referencing the control?
See the detailed info in Allen Browne's #3

=txtCustomerCount

imad hammad wrote in message
:
I have read this suggestion in a different post as well and i still can't get
it to work.

When I set the control source, for my text box in the reports footer, to
[txtCustomerCount] (or any text box for that matter) i get a "No such Field
in the Field List" error. Please help thank you.

"Tim Long" wrote:

I'm learning! Many thanks for taking the time and trouble to explain.

Tim Long

"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




--
Roy-Vidar

  #6  
Old August 21st, 2005, 06:10 PM
imad hammad
external usenet poster
 
Posts: n/a
Default

I actually forgot the [], but now I am not getting the result i want exactly.

My count in the Report footer is counting correctly (there are a bunch of
spaces between the counts in the report but i plan on setting visiblity to
none). However when i place the text box in the report header (the final
step) the count it displays is always 1.

So in the example Alan wrote

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]

This step will count properly (up to 5 in my report)

but then the following step will always display a count of 1
4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Thank you very much for your help

"RoyVidar" wrote:

Did you just forget the equal sign when referencing the control?
See the detailed info in Allen Browne's #3

=txtCustomerCount

imad hammad wrote in message
:
I have read this suggestion in a different post as well and i still can't get
it to work.

When I set the control source, for my text box in the reports footer, to
[txtCustomerCount] (or any text box for that matter) i get a "No such Field
in the Field List" error. Please help thank you.

"Tim Long" wrote:

I'm learning! Many thanks for taking the time and trouble to explain.

Tim Long

"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




--
Roy-Vidar


  #7  
Old August 21st, 2005, 07:03 PM
RoyVidar
external usenet poster
 
Posts: n/a
Default

Sorry, I don't know - Allen Browne's suggestion works
on my setup - you are sure you are referencing the
correct control?

imad hammad wrote in message
:
I actually forgot the [], but now I am not getting the result i want exactly.

My count in the Report footer is counting correctly (there are a bunch of
spaces between the counts in the report but i plan on setting visiblity to
none). However when i place the text box in the report header (the final
step) the count it displays is always 1.

So in the example Alan wrote

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]

This step will count properly (up to 5 in my report)

but then the following step will always display a count of 1
4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Thank you very much for your help

"RoyVidar" wrote:

Did you just forget the equal sign when referencing the control?
See the detailed info in Allen Browne's #3

=txtCustomerCount

imad hammad wrote in message
:
I have read this suggestion in a different post as well and i still can't
get it to work.

When I set the control source, for my text box in the reports footer, to
[txtCustomerCount] (or any text box for that matter) i get a "No such Field
in the Field List" error. Please help thank you.

"Tim Long" wrote:

I'm learning! Many thanks for taking the time and trouble to explain.

Tim Long

"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do
not wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value
into the report footer after the report runs right through, and then
carry it back to the report header section as it makes its 2nd pass on
the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the
number of
customers appearing in my the query result that underlies the report.
The query is called qryOrders and the field I want to count is Customer.
I have
for example 20 orders from ten customers. Can you tell me what function
I need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




--
Roy-Vidar



--
Roy-Vidar

  #8  
Old November 14th, 2005, 09:36 PM
seswho704
external usenet poster
 
Posts: n/a
Default Counting unique values in a report

Allen,

Thank you for the insight on this. I was able to use your idea and mixed it
with some info from a Duane Hookom in another thread and was able to get the
counts I was looking for. The only question I have is, when I run the
report, there is a chance I'll get 0 records from my queries. In this case,
I get #Error in the text boxes where my counts should show zeros. Is there a
way to have it show zeros instead of #Error
--
--
Steve Steiner



"Allen Browne" wrote:

1. Add a group header for your CustomerID field (Sorting And Grouping, on
View menu). You can set this section's Visible property to No if you do not
wish to see it.

2. In this section, add a text box with these properties:
Control Source =1
Running Sum Over All
Name txtCustomerCount
Format General Number

3. In the Report Footer section, add a text box with these properties:
Control Source = [txtCustomerCount]
Name txtCustomerCountFooter
Format General Number
Visible No

4. In the Report Header section, you should now be able to add a text box
with Control Source set to:
=[txtCustomerCountFooter]

Without testing, I think that should work. Access will drop the value into
the report footer after the report runs right through, and then carry it
back to the report header section as it makes its 2nd pass on the report.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Tim Long" wrote in message
...
Hello, I want to have a text box in my report header displaying the number
of
customers appearing in my the query result that underlies the report. The
query is called qryOrders and the field I want to count is Customer. I
have
for example 20 orders from ten customers. Can you tell me what function I
need to put into the control source of my text box to get the simple
result
"10"?

Many thanks in advance

Tim Long




  #9  
Old November 14th, 2005, 11:39 PM
Marshall Barton
external usenet poster
 
Posts: n/a
Default Counting unique values in a report

seswho704 wrote:
Thank you for the insight on this. I was able to use your idea and mixed it
with some info from a Duane Hookom in another thread and was able to get the
counts I was looking for. The only question I have is, when I run the
report, there is a chance I'll get 0 records from my queries. In this case,
I get #Error in the text boxes where my counts should show zeros. Is there a
way to have it show zeros instead of #Error



Instead of using:
=txtCustomerCount

try using an expression like:
=IIf(IsError(txtCustomerCount), 0, txtCustomerCount)

--
Marsh
MVP [MS Access]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unique Values vs Unique Records Miaplacidus Running & Setting Up Queries 1 September 17th, 2004 08:24 PM
Counting Records in a Access Report Armando B. General Discussion 1 August 10th, 2004 06:32 PM
Save Report With CreateReport Coding Issue Jeff Conrad Setting Up & Running Reports 8 July 12th, 2004 08:39 AM
Counting Unique Values Emma Hope Worksheet Functions 4 May 9th, 2004 11:40 PM


All times are GMT +1. The time now is 07:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.