Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

access 2000 report

Status
Not open for further replies.

Hasu

Programmer
Jul 7, 2003
42
CA
i have this report and i want to get the count at the end of page
here is the layout of the report

Id Name Gender
11 test M
22 test1 F
33 test2 M
44 test3 F

At the end of page i want to get a count where is gets the
Males = 2 Female = 2

How can i write a VBA code
rs.Open "Select * from test Where Gender='" & Me!Gen & "' and Id=" & Me!ID & " Order By Gender", SASConnection, adOpenForwardOnly, adLockReadOnly

Do Until rs.EOF = True
If Me!Gen = "F" Then
FCnt = FCnt + 1

Else

If Me!Gen = "M" Then
MCnt = MCnt + 1

End If
End If

rs.MoveNext
Loop
Me.Females1 = FCnt
Me.Males1 = MCnt

rs.Close: Set rs = Nothing
FCnt = 0
MCnt = 0


can someone help me
 
The following code assumes these 2 things:
1) You have a field named "Gender" in the record source of the report.
2) You have two unbound fields in the Report Footer called txtMales, and txtFemales.

If this is not the case, then adjust the code accordingly.

On your report, put the following in the general declerations section:

=============================================
Private totMales As Integer
Private totFemales As Integer
=============================================

Put the following on the Detail_Format Event:

=============================================
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Static males As Integer
Static females As Integer

If Me.Gender = "m" Then
males = males + 1
totMales = males
Else
females = females + 1
totFemales = females
End If
End Sub
=============================================

Put the following on the ReportFooter_Format event:

=============================================
Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
Me.txtMales = totMales
Me.txtFemales = totFemales
End Sub
============================================= Jim Lunde
compugeeks@hotmail.com
We all agree your theory is crazy, but is it crazy enough?
 
thanks for your help. i forgot to mention that i have the report sorted by homeroom and i have to have the txtmales and txtfemales on the homeroom footer. if i put it in the report footer it give me all the totals.
can you please help me.
your help is greatly appreciated.
 
thanks for your help. i got it working
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top