Why I am getting error with sum function.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wassimdaccache
    New Member
    • Apr 2007
    • 222

    Why I am getting error with sum function.

    Dear Sir,


    I have a continuous form base on union of 2 queries.

    A field date called [dates] and another textbox called receipt_sum

    the source of the receipt_sum is
    Code:
     =nz(DSum("total","table_mov","[date]=[dates]" & " And" & "[free]=false" & " and" & "[save]=true"),0)
    on the footer of the my form I am trying to assign another textbox with the source below:

    Code:
     =sum([receipt_sum])
    An error is always occurred the caption of my textbox on the footer is always [#error]

    NB: I am sure about the name of the field.

    any idea plz


    thank you in advance.


    WASSIM S DACCACHE
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    I'm not sure that it will actually work, but I do know your syntax is incorrect. You must include the entire expression in the Footer Summation for [receipt_sum], you cannot simply refer to the Field containing the expression, as in:
    [CODE=vb]
    =Sum(nz(DSum("t otal","table_mo v","[date]=[dates]" & " And" & "[free]=false" & " and" & "[save]=true"),0))[/CODE]

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      I think that's exactly right. You cannot simply run a function like Sum() on a control that holds a calculated value, you have to run it on the expression used for the calculation.

      Linq ;0)>

      Comment

      • wassimdaccache
        New Member
        • Apr 2007
        • 222

        #4
        Originally posted by ADezii
        I'm not sure that it will actually work, but I do know your syntax is incorrect. You must include the entire expression in the Footer Summation for [receipt_sum], you cannot simply refer to the Field containing the expression, as in:
        [CODE=vb]
        =Sum(nz(DSum("t otal","table_mo v","[date]=[dates]" & " And" & "[free]=false" & " and" & "[save]=true"),0))[/CODE]
        Thank you for your quick reply. I acknowledge that it is working well.


        But actually I am a little bit confused with the function dsum.

        Does dsum function go to the table and do the sum base on the criteria set on the expression or it does the sum of the form criteria + criteria on the expression. ?


        Any suggestion would be appreciated.


        Thank you in advanced.

        WASSIM S DACCACHE
        CCE

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by wassimdaccache
          Thank you for your quick reply. I acknowledge that it is working well.


          But actually I am a little bit confused with the function dsum.

          Does dsum function go to the table and do the sum base on the criteria set on the expression or it does the sum of the form criteria + criteria on the expression. ?


          Any suggestion would be appreciated.


          Thank you in advanced.

          WASSIM S DACCACHE
          CCE
          DSum() calculates the SUM of a set of values in a specified set of Records called a Domain. Criteria can be set based on Fields contained within the Domain. The summation will be done on the [total] Field of the table_mov Table, based on your criteria.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            Wassim, You need to make the Help system your friend.

            Try this :
            1. Open Access.
            2. Use Alt-F11 to switch to the VBA window.
            3. Use Ctrl-G to go to the Immediate pane.
            4. Type DSum.
            5. Press F1.

            This will find the Help page associated with this function and this has a lot of information that will help you understand it more fully. It explains all the arguments in detail.

            This is called Context-Sensitive Help, and is a very useful thing to know and use.

            Comment

            Working...