# Thread: help with report calculation

1. Registered User
Join Date
Sep 2001
Posts
175

## Unanswered: help with report calculation

Can someone help me with the following calculation?

I have a report with a column with the following:

field1 = 10.00
field2 = 20.00 (not visible)
field3 = 30.00 (not visible)
field4 = 40.00

Total ?

How can I total the values where the fields are visible therefore my total should be 50.00? Keep in mind that the non-visible fields have values in them.

NEED HELP URGENTLY

2. Registered User
Join Date
Feb 2002
Location
Leuven, Belgium
Posts
27
Hi,

I have done similar things using forms. Just check all the controls in your form of the type text. If they are visible add up else do nothing

Private sub CountTotal(ctrl As Controls)

Const vbTextBox = 109 ' means is textbox

Dim intProperty As Integer
dim intTotal as integer
Dim i As Integer

intTotal = 0

For i = 0 To ctrl.Count - 1
intProperty = ctrl(i).Properties("ControlType")
If intProperty = vbTextBox And ctrl(i).visible Then
intTotal = intTotal + ctrl(i).value
End If
Next i

MyReport.total = intTotal

End Sub

call the function like this:
countTotal MyReport.Controls

I hope that it also works for reports but I think you can use this in the On_Open event of your report.

hope it helps

anna

3. Registered User
Join Date
Sep 2001
Location
Chicago, Illinois, USA
Posts
603
toukey1,

Can you give us a bit more detail?

Are fields one through four, four separate textboxes in the detail section of your report.

Are they each bound to the report's sourceobject?

Why are fields two and three invisible? Are you toggling them invisible in the OnFormat event of the detail section.

Is this total field in the detail section of the report, or in some footer section?

Ken

4. Registered User
Join Date
Apr 2002
Location
Portugal
Posts
146
Hi!

Try to use the function 'IF()', in the control source property

or

had a new control to do parcial sums