sum or Dsum?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lulu123
    New Member
    • Jan 2008
    • 12

    sum or Dsum?

    i have a textbox in a form. Where i want it to calculate the total of hours for different employees in different month.

    when i use "=sum([hour])" it gives the the total of all employee in all of the monthes.
    and when i use Dsum as " = DSum( "[Hour]", "[tablename]", "[MonthID]" =1)", it gives me the total of all employee in January.

    my question is, what should i do to make it only calculate the total hour of only the one specific employee and one specific month.
  • jaxjagfan
    Recognized Expert Contributor
    • Dec 2007
    • 254

    #2
    Originally posted by lulu123
    i have a textbox in a form. Where i want it to calculate the total of hours for different employees in different month.

    when i use "=sum([hour])" it gives the the total of all employee in all of the monthes.
    and when i use Dsum as " = DSum( "[Hour]", "[tablename]", "[MonthID]" =1)", it gives me the total of all employee in January.

    my question is, what should i do to make it only calculate the total hour of only the one specific employee and one specific month.
    = DSum( "[Hour]", "[tablename]", "[MonthID]" =1 AND "[EmpID]" =1)

    The criteria of the DSUM works just like a Where clause without "Where".

    Comment

    • lulu123
      New Member
      • Jan 2008
      • 12

      #3
      hi, thanks for replying, jaxjagfan..
      but, it still didn't solve my problem, i don't think i explained it clear enough...

      the problem is that, this mainform has a subfrom. the main form contains employeeID, and the subform is where employee can enter their own hours and monthes....and on the main from footer, i have this textbox, where i want it calculate the total hours for each month. So, if i use " empID=1" , it will only give me value for EmployeeI , not total hours to the related employee.

      i tried to make a query, it gives me the right answer.(where shows the diffeerent month total hours to related employee name). However, i dno't know how to make the result to show on my mainform ?

      Do you know hwo can i solve that? Thanks.

      Originally posted by jaxjagfan
      = DSum( "[Hour]", "[tablename]", "[MonthID]" =1 AND "[EmpID]" =1)

      The criteria of the DSUM works just like a Where clause without "Where".

      Comment

      • jaxjagfan
        Recognized Expert Contributor
        • Dec 2007
        • 254

        #4
        Originally posted by lulu123
        hi, thanks for replying, jaxjagfan..
        but, it still didn't solve my problem, i don't think i explained it clear enough...

        the problem is that, this mainform has a subfrom. the main form contains employeeID, and the subform is where employee can enter their own hours and monthes....and on the main from footer, i have this textbox, where i want it calculate the total hours for each month. So, if i use " empID=1" , it will only give me value for EmployeeI , not total hours to the related employee.

        i tried to make a query, it gives me the right answer.(where shows the diffeerent month total hours to related employee name). However, i dno't know how to make the result to show on my mainform ?

        Do you know hwo can i solve that? Thanks.
        DSum( "[Hour]", "[tablename]", "[MonthID]" =1 AND "[EmpID]" = & Me.FormEmployee IDControl)

        Should be something like that. When you sum on month just remember that is All Month 1's or all January's. Make sure you include Month Year combinations at a minumum to get correct totals.

        Comment

        Working...