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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUM not correct, Adding it self twice, I need some help...

Status
Not open for further replies.

beatomatic

Technical User
Aug 29, 2003
2
US
I am currently trying to run a report based on a SQL query. I have a field called "Wage" that I am summing up, for each employee, which are grouped under a manager. So, in my report I have two groups, the first is Manager, and the Second is Employee, followed by the detail section. I am doing my calculations in the VB code, and it is something like this:


-----------------------------------------------------------
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

txtManagerTotal = txtWage + txtManagerTotal
txtEmployeeTotal = txtWage + txtEmployeeTotal

End Sub

Private Sub GroupHeader0_Format(Cancel As Integer, FormatCount As Integer)

txtManagerTotal = 0

End Sub

Private Sub GroupHeader2_Format(Cancel As Integer, FormatCount As Integer)

txtEmployeeTotal = 0

End Sub
-----------------------------------------------------------

I do not have the "Keep Group together" feature enabled. What happens is, whenever an Employee's details are broken across two pages, it adds the wage from the previous page twice, so the txtEmployeeTotal field displays a sum that has the one wage field added twice.

I tried to fix this by enabling the "keep group together" feature, and when I did this it added the txtManagerTotal field to itself twice, so that now the txtManagerTotal field is twice what it should be.

Any ideas on how to fix this? I would greatly appreciate it, this is driving me crazy.

Thanks,

James
jameswhited@lycos.com
 
Since you already have manager and employee grouped, simply add a text box to each group footer and set its control source to:
Code:
=Sum([txtWage])

Hoc nomen meum verum non est.
 
that is it, thank you, very, very much Doctor Martin Von Nostrand.

Now i can sleep easily...
 
Giddyup!!!!

10002122.jpg


Hoc nomen meum verum non est.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top