Results 1 to 13 of 13
  1. #1
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65

    sumif in Access

    Hello,



    I'm trying to sum the production output for all the Work Order numbers that are the same over a 52 week period. For example, I want to create a report for Week 3 and have all the work orders for that week be shown along with the total production for each work order for that week and the total production for that work order from weeks 1, 2 and 3.
    Example data:
    W/O: 12345A Week1= 10, Week2= 20, Week3= 35
    W/O: 6789B Week1= 15, Week2= 0, Week3= 45
    W/O: 01010C Week1=150, Week2= 50 Week3= 100

    Week # W/O Weekly Total W/O Total
    3 12345A 35 65
    3 6789B 45 60
    3 01010C 100 300

    Is there a way to do this? If so, should I do this in a query or in the report?

    Any help would be much appreciated. Thanks!

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    If you want to show detail data, do the summation in report. Use report Grouping & Sorting with aggregate calcs in group and report footers.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    See the attached. I created two aggregate queries. If you want the information in one report, then you will have to create a report and use the queries as the record source for the report.

    Edit: Slow again--or use June's idea.
    Attached Files Attached Files

  4. #4
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Alansidman,

    Thanks for the reply, but when I try to open query 2 I get this pop-up (Query1.SumOfWOAmount). What do I do?

  5. #5
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    June7,

    I have over 100 different Work Order Numbers and I don't want to have the total shown below each W/O. I want to have it show the total in the same row as the Work Order. Can this be done?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    You want the total to show in each detail record? Yes, can be done. One is to build an aggregate (GROUP BY) query that groups on workorder and sums the Total fields. Join that query to the detail data source. The aggregate calcs will show in each row.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Sorry about the error. I fixed in attached and incorporated June's suggestion
    Attached Files Attached Files

  8. #8
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    June7 and Alansidman,

    Thank you both for your help!! Last question, is there a way for me to create a report that automatically opens up the current week instead of having to input the number myself. For example, if week 3 are the dates 1/14 - 1/19 and the current date is 1/17, then I want the report to open week 3. If the current date is 1/21, then I want the report to open week 4. Is there a way to do this?

  9. #9
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You will have to build a table with the week numbers and the date range. Three fields. Then apply criteria to the week number in your query that determines the current week number based upon the current date. You will have to join the two tables on the week number. Look at the attached.
    Attached Files Attached Files

  10. #10
    JGrots is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Jan 2013
    Posts
    65
    Alansidman,

    Thank you for all your time and help! It is much appreciated!

  11. #11
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    You are welcome.

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Alan & JGrots, actually the weeknumber can be calculated with Format function.

    Format(Date(),"ww")
    That expression uses the defaults of vbSunday as first day of week and vbFirstJan1 as first day of year.

    Format(Date(),"w")
    I think returns day of week - better to use Weekday(Date())

    Format(Date(),"www")
    using more than 2 w's returns something I don't know what it is
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    June

    Thanks. Didn't think to go in that direction. Nice addition.


    alan

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

Similar Threads

  1. Complex "sumif" style formula
    By groonpooch in forum Queries
    Replies: 3
    Last Post: 12-16-2011, 07:05 PM
  2. Lookup and Sumif
    By hatimn in forum Queries
    Replies: 7
    Last Post: 07-18-2011, 11:50 AM
  3. Sumif in an Access report
    By tigers in forum Reports
    Replies: 0
    Last Post: 03-15-2007, 12:19 PM

Tags for this Thread

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