Count number of months

  • Thread starter Thread starter Pedro
  • Start date Start date
P

Pedro

Hi everyone
I have a report that groups for month several records and
give me the total for each month.
Question : How do i kow how many months?
On the last line, grand total, can i have how many months
is my report, like "=Count([Month]). It's suppose to tell
me 4 or 5, and instead it tells me the number of records
for all months. I need that number to work it with another
field.
Tks in advance
Pedro
 
Pedro;
This is some old code from Access 2.0, but I think
it still works. Is was for 100 Years.

Private Sub Command1_Click()

Dim AllMonths(1200) As Byte
Dim wrkbytMonth As Byte
Dim intCntElements As Integer

wrkbytMonth = DatePart("m", Date)

Do While AllMonths(intCntElements) > 0
If AllMonths(intCntElements) = 0 Then
AllMonths(intCntElements) = wrkbytMonth
intCntElements = intCntElements + 1
Else
If AllMonths(intCntElements) <>
wrkbytMonth Then
intCntElements = intCntElements + 1
Else
Exit Do
End If
End If
Loop

intCntElements = 0

Do Until AllMonths(intCntElements) = 0
intCntElements = intCntElements + 1
Loop

End Sub
 
Tony

Tks lot for your anser but ...
I have a field named Text78 and i would like to put there
that value. what and how do i do? don't understand nothing
about VBA, sorry. Can i do anything?
Tks in advance
Pedro
-----Original Message-----
Pedro;
This is some old code from Access 2.0, but I think
it still works. Is was for 100 Years.

Private Sub Command1_Click()

Dim AllMonths(1200) As Byte
Dim wrkbytMonth As Byte
Dim intCntElements As Integer

wrkbytMonth = DatePart("m", Date)

Do While AllMonths(intCntElements) > 0
If AllMonths(intCntElements) = 0 Then
AllMonths(intCntElements) = wrkbytMonth
intCntElements = intCntElements + 1
Else
If AllMonths(intCntElements) <>
wrkbytMonth Then
intCntElements = intCntElements + 1
Else
Exit Do
End If
End If
Loop

intCntElements = 0

Do Until AllMonths(intCntElements) = 0
intCntElements = intCntElements + 1
Loop

End Sub


-----Original Message-----
Hi everyone
I have a report that groups for month several records and
give me the total for each month.
Question : How do i kow how many months?
On the last line, grand total, can i have how many months
is my report, like "=Count([Month]). It's suppose to tell
me 4 or 5, and instead it tells me the number of records
for all months. I need that number to work it with another
field.
Tks in advance
Pedro
.
.
 
Make sure you have a month header. Add a text box to the header section:
Name: txtCountMth
COntrol Source: =1
Running SUm: Over All

Then add a text box to your report footer:
Control Source: =txtCountMth
 
Back
Top