Finding out the number of records

A

alunnie

Hi~

I need to generate a report consisting of all of the company names from
a particular industry. I set the criteria of the Industry to the
specific type and generated a report, how do I make a field in the
report to show the number of companies from that specific industry?

Many Thanks!
 
O

Ofer

You can create an industry Footer, in the footer put a text field
on the on print event of the footer write some code, use the dcount to count
the number of records.
if field Industry is number
me.textfield.value = dcount("*","companyTable", "Industry = "& me.Industry)

if field Industry is Text
me.textfield.value = dcount("*","companyTable", "Industry = '"& me.Industry
& "'")

There other ways, like count number that been printed and then display it,
but in that case more code involved.
or create another field in your query with value 1, and then you can count
it in the report, running sum.
 
M

Marshall Barton

alunnie said:
I need to generate a report consisting of all of the company names from
a particular industry. I set the criteria of the Industry to the
specific type and generated a report, how do I make a field in the
report to show the number of companies from that specific industry?


As long as the report's record source query returns each
company name exactly once, you can use a text box in the
Report Header and/or Footer section (or any group
header/footer) with the expression =Count(*)

If the record source query has multiple records with the
same company name, then add the company name field to the
Sorting and Grouping list (View menu). Specify Yes for the
group header or footer. Now add a text box named
txtRunCoCnt to the group header/footer. Set its control
source expression to =1 and set its RunningSum property to
Over All. Then a Report Footer text box can display the
total count of unique company names by using the expression
=txtRunCoCnt
 
Top