Results 1 to 6 of 6
  1. #1
    jackjfarrell is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Jun 2016
    Posts
    3

    DSUM Querry

    I am trying to create a Dsum for a query. Right now I have 4 different Workorders and several different types of workers who have labor hours associated with those workorders. I want to sum the amount of labor hours employee type "Project_Crew" has. Each time I try it gives the the sum for all workorders not just the row I want. If the picture attached there is only 1 employee with 8 hours of time for workorder 123 but it is showing in the right column that each workorder has 8 hrs when it should show that only 123 has 8 hrs. What am I doing wrong. Thanks





    This is the expression i entered into the Query.


    ProjectCrewST: DSum("[HoursWorked]","DSUM","[Craft]='Project_Crew' AND [Workorder]=[Workorder]")


    Click image for larger version. 

Name:	DsumForm.JPG 
Views:	16 
Size:	28.9 KB 
ID:	25114

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    don't use DSUM in a query. The QUERY is the dsum.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,445
    I agree with ranman, but perhaps you can fix your dsum by fixing the criteria

    ProjectCrewST: DSum("[HoursWorked]","DSUM","[Craft]='Project_Crew' AND [Workorder]=" & [Workorder])

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I don't know if this will work or not, but your DSUM criteria is wrong:

    In this: ProjectCrewST: DSum("[HoursWorked]","DSUM","[Craft]='Project_Crew' AND [Workorder]=[Workorder]"), the bolded part is inside the quotes, so it's like saying 1 = 1, which of course is always true, so essentially your DSUM criteria is ","[Craft]='Project_Crew' " and that's all.

    You could try this: "[Craft]='Project_Crew' AND [Workorder] = " & [Workorder] as the DSUM criteria, but as I say, I don't know if it will work.

    (Sorry Ajax - I didn't see your post!)

  5. #5
    jackjfarrell is offline Novice
    Windows 8 Access 2013 32bit
    Join Date
    Jun 2016
    Posts
    3
    Thanks for your help. How would I do it without a DSUM? What would the expression look like.

  6. #6
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You could try a calculated field in the query:

    ProjectCrew:iif([Craft]='Project_Crew', [HoursWorked], 0)

    and sum it as you did for the other two query fields.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update Querry
    By Daryl2106 in forum Access
    Replies: 6
    Last Post: 08-29-2013, 11:09 AM
  2. Search querry
    By sdc1234 in forum Queries
    Replies: 14
    Last Post: 06-22-2013, 08:21 AM
  3. Querry help with Dates
    By jimhmason in forum Access
    Replies: 1
    Last Post: 11-09-2011, 04:36 PM
  4. Update Querry
    By wrenchman123 in forum Queries
    Replies: 0
    Last Post: 02-05-2011, 07:21 AM
  5. Querry formating
    By Zoroxeus in forum Queries
    Replies: 0
    Last Post: 03-07-2006, 11:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums