Count Years

AN60

Registered User.
Local time
Today, 13:02
Joined
Oct 25, 2003
Messages
283
I have used the following in a query to group rainfall into years;
DateYEAR: Year([datefield])
This works fine and gives a list grouped by year.
I now want to count the number of years listed in the dateyear column.Not individual entries but the years.
eg. 1991, 1991, 1992, 1991 would be three 1991's & one 1992.
My attempts so far have not been successful, can it be done in the query or report, any ideas?
 
You can do this easily with a report. Set up a query with just a single column having the expression:

=Year([DateField])

That will become Expr1 in the query.

Now start a new report in design view using the above query as the record source. Close up the detail section, you won't need it. Go into Sorting And Grouping and select Expr1, sort ascending, Page Header = Yes.

Now inside the Expr1 header, add 2 text boxes. Set the control source of the first one to Expr1, and the control source of the second one to =Count(*).

View the report and you will see each year with a count of that year next to it.
 
Add an unbound textbox to the Group header/footer, set its control source to =1, set the Running Sum to over all, you now have a count of the Groups on your Report
 
Thank you both for your prompt replies. I have used Rich's (looked a bit easier + I am lazy) and it works nicely. Without this forum my DB's would be in the Dark Ages. :)
 

Users who are viewing this thread

Back
Top Bottom