Count in a report

G

Guest

Hi-
I'm trying to count my detail records in a report. I have created a group
footer for the records I want to count and tried =Count(*) and it placed a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 
G

Guest

I was having the same issue myself, what I was able to do to to get a count
was to simply make a module that does the counting and then in the report I
just run the function. I'll paste the code I have for the module and the
function that I run in the report.

The module basically consists of this:
---------------------------------------------------------
Option Compare Database

Option Explicit
Dim mlngCounter As Long

Function ResetCounter()
mlngCounter = 0
End Function

Function GetNextCounter(Pvar As Variant) As Long
mlngCounter = mlngCounter + 1
GetNextCounter = mlngCounter
End Function
-----------------------------------------------------

and then in the report I had a simple text box, and made the control source
of it as:

=GetNextCounter([Date])

That would print out the numbers like
1
2
3
4

The only thing is the reprint of the 4, and that probably could be solved
just by adding another text box at the very end of the report with a:

=GetNextCounter([Date]) -1

The reason you would do the -1 is to decrement it back down to the original
number. There is probably a better way of doing it like a variable and just
printing out that variable again on that last text box, but I am still fairly
new at Access and don't want to give you bad info. If anyone else knows how
to do this, I would be interested in finding out also. Let me know if this
helps you any..

V/R
Leroy :)
 
D

Duane Hookom

Adding a text box in a group or report footer with a control source of:
=Count(*)
should display a count of all detail records.
If you got a count of 1 under each directory, consider moving the text box
to the zip code (or other group) footer.
 
D

Duane Hookom

If you want a running count in the detail section, don't use code. Add a
text box in the detail section with these properties:
Control Source: =1
Running Sum: Over All (or Over Group)

--
Duane Hookom
MS Access MVP
--

Leroy said:
I was having the same issue myself, what I was able to do to to get a count
was to simply make a module that does the counting and then in the report
I
just run the function. I'll paste the code I have for the module and the
function that I run in the report.

The module basically consists of this:
---------------------------------------------------------
Option Compare Database

Option Explicit
Dim mlngCounter As Long

Function ResetCounter()
mlngCounter = 0
End Function

Function GetNextCounter(Pvar As Variant) As Long
mlngCounter = mlngCounter + 1
GetNextCounter = mlngCounter
End Function
-----------------------------------------------------

and then in the report I had a simple text box, and made the control
source
of it as:

=GetNextCounter([Date])

That would print out the numbers like
1
2
3
4

The only thing is the reprint of the 4, and that probably could be solved
just by adding another text box at the very end of the report with a:

=GetNextCounter([Date]) -1

The reason you would do the -1 is to decrement it back down to the
original
number. There is probably a better way of doing it like a variable and
just
printing out that variable again on that last text box, but I am still
fairly
new at Access and don't want to give you bad info. If anyone else knows
how
to do this, I would be interested in finding out also. Let me know if this
helps you any..

V/R
Leroy :)

Michael Anne said:
Hi-
I'm trying to count my detail records in a report. I have created a group
footer for the records I want to count and tried =Count(*) and it placed
a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 
G

Guest

In the field you created in the group footer, write
= Count([Field Name You created The Footer For])
 
G

Guest

Ofer-
I did that type of count also, and came up with the same result.
The zipcode is in the Zipcode header and the directoryis listed in the
details section, and then I created the Directory footer and placed the text
box in there.
The idea of code is very scary. I am self taught with Access, so my
knowledge is very limited.
Thank you

Ofer said:
In the field you created in the group footer, write
= Count([Field Name You created The Footer For])

Michael Anne said:
Hi-
I'm trying to count my detail records in a report. I have created a group
footer for the records I want to count and tried =Count(*) and it placed a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 
D

Duane Hookom

As per my previous reply, is there a reason you created and used a Directory
footer rather than a ZipCode footer?

--
Duane Hookom
MS Access MVP


Michael Anne said:
Ofer-
I did that type of count also, and came up with the same result.
The zipcode is in the Zipcode header and the directoryis listed in the
details section, and then I created the Directory footer and placed the
text
box in there.
The idea of code is very scary. I am self taught with Access, so my
knowledge is very limited.
Thank you

Ofer said:
In the field you created in the group footer, write
= Count([Field Name You created The Footer For])

Michael Anne said:
Hi-
I'm trying to count my detail records in a report. I have created a
group
footer for the records I want to count and tried =Count(*) and it
placed a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 
G

Guest

I used the Directory footer because that is what I wanted to count within the
zipcode. The assistance page on the topic by Sal Ricciardi (July 20, 2004),
read (to me) to create a footer for the detail field I wanted a total count
on.

Thank you-

Duane Hookom said:
As per my previous reply, is there a reason you created and used a Directory
footer rather than a ZipCode footer?

--
Duane Hookom
MS Access MVP


Michael Anne said:
Ofer-
I did that type of count also, and came up with the same result.
The zipcode is in the Zipcode header and the directoryis listed in the
details section, and then I created the Directory footer and placed the
text
box in there.
The idea of code is very scary. I am self taught with Access, so my
knowledge is very limited.
Thank you

Ofer said:
In the field you created in the group footer, write
= Count([Field Name You created The Footer For])

:

Hi-
I'm trying to count my detail records in a report. I have created a
group
footer for the records I want to count and tried =Count(*) and it
placed a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 
D

Duane Hookom

Find your more recent thread and work from there.

--
Duane Hookom
MS Access MVP
--

Michael Anne said:
I used the Directory footer because that is what I wanted to count within
the
zipcode. The assistance page on the topic by Sal Ricciardi (July 20,
2004),
read (to me) to create a footer for the detail field I wanted a total
count
on.

Thank you-

Duane Hookom said:
As per my previous reply, is there a reason you created and used a
Directory
footer rather than a ZipCode footer?

--
Duane Hookom
MS Access MVP


Michael Anne said:
Ofer-
I did that type of count also, and came up with the same result.
The zipcode is in the Zipcode header and the directoryis listed in the
details section, and then I created the Directory footer and placed the
text
box in there.
The idea of code is very scary. I am self taught with Access, so my
knowledge is very limited.
Thank you

:

In the field you created in the group footer, write
= Count([Field Name You created The Footer For])

:

Hi-
I'm trying to count my detail records in a report. I have created a
group
footer for the records I want to count and tried =Count(*) and it
placed a
count of 1 under each directory. This is what I'm trying to do:

ZipCode Directories Covered
44907 Directory 1
Directory 2
Directory 3
Total number of Directories 3

Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top