Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    17

    Exclamation Unanswered: How can i sum textbox that calculated from function ?

    I have 2 textboxs.
    First textbox is in detail section
    And
    Second textbox is in GroupFooter0 section

    I have written the funtion for calculate first textbox .
    And I want to sum second textbox too.

    I used to use Sum([first textbox]) on Control Source of the second textbox
    But It occured the input dialog and show the name of first textbox before show the report (the input dialog show after click open the report)
    ^
    What cause does this problem has?

    So, I have written another function for sum second textbox (cuz Could not sum with Sum([first textbox]) )
    ----
    The code of last function is:

    Function SumMPay(longMPay As Long) As Long
    Dim i As Integer
    Set dbs = CurrentDb()
    Set rst = dbs.OpenRecordset("select deb_id from deb_list where deb_month= " & Reports![Deb_List_Report_By_Month]![Deb_Month] & " and deb_year = " & Reports![Deb_List_Report_By_Month]![Deb_Year])
    rst.MoveLast
    rst.MoveFirst

    For i = 1 To rst.RecordCount
    SumMPay = SumMPay + longMPay
    Next i

    End Function
    ---
    And
    I have used this function at :

    Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)
    second textbox = SumMPay(first textbox)
    End Sub
    ----
    Now Can open the report without any input dialog and
    Second textbox can show the value
    But
    some value on the second textbox incorrect !
    Which wrong?
    Anyone have any idea ?

    Please Help me
    I am using winxp + office 2k sp3

    Thank you very much.

  2. #2
    Join Date
    Mar 2004
    Posts
    17

    Question

    Hey
    I used to put the second textbox on PageFooterSection
    By use Sum([first textbox])

    But it shows #Error
    And
    I have tried put the second textbox on PageFooterSection again
    But by use Function SumMPay(longMPay As Long) As Long

    Then it was incorrect like put on GroupFooter
    (I have changed the code to
    "Private Sub PageFooterSection_Print(Cancel As Integer, PrintCount As Integer)
    Me.SumM1Pay = SumMPay(Me.M1Pay)
    End Sub" too)

    *If that report just has a record , The value would been correct
    But If that report has more than 2 records , The value would been incorrect

    How should i do ?
    Thanks all

  3. #3
    Join Date
    Dec 2003
    Location
    WA, USA
    Posts
    51
    If it is possible it is much easier to sum the field from the input query.
    >> If the field you want view and sum is lets say [Item Cost] then text box 1 (In detail) will have a control source of "[Item Cost]". then in your footer text box 2 will have a control source of "=SUM([Item Cost])"
    Bob

  4. #4
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    iBug,

    did you get the sample I posted to you on your other similar post???

    Bud

  5. #5
    Join Date
    Mar 2004
    Posts
    17

    Exclamation

    Hey friend.
    I forget told u that I have already used "=Sum([first textbox])" at the control source of second textbox .
    Then I have tried use over group or over sum at running sum property of second textbox too.

    But when open the report (Now no using my function)
    it occured the input dialog (input parameter dialog) yet.

    I thought occurrence the input dialog before the report will be opened will relate with the control source of both textboxs ?

    cuz There is the name of first textbox at the input dialog .
    cuz The control source of first textbox had not get from the table , but the value of first textbox got from calculation of my function(first textbox is just summation of my function).

    So, It occured the input dialog !
    So i could not use =Sum() ?!

    Please help me again , I am sorry for repeat post (but I have edited my post in another post)

    Thanks .

  6. #6
    Join Date
    Jun 2004
    Posts
    96
    ibug, from your codes, are you are trying to compute total payout for each month? and this report is "Deb_List_Report_By_Month"??

    But is it necessary to create functions to compute the textbox values based on the same report, when the values are all found on the report/query already.

    Cyherus

Posting Permissions

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