Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2001
    Posts
    175

    Question 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. #2
    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. #3
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    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. #4
    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
    you had 4 controls in your report: field1; field2(N.V); field3(N.V); field4
    create a control for example: field5, in the control source put
    =[field1]+[field4]

    Now you can have a parcial sum
    Last edited by Miguel; 04-13-02 at 01:51.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •