Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Query Sum based on date range
Rose Lavoie 
  
2 years ago
I am building a query for my database to return the total value of the following:

Manual Hours
Wire Hours
CNC Hours

During specific time frames (previous month, currently month and next month).

The 2 tables I am pulling from are:

QuoteHRS
tblAPQP

Linked Fields= WONumber & Part Numbers

I want to write an expression to give me the total of each field for previous month, current month and next month. I've tried in my query:

IIF(Year([DueDate])* 12 + DatePart("m",[DueDate]) = Year(Date())* 12 + DatePart("m",Date())-1  

However, not sure how to return the total value of each field for each time period.

Any help would be great.

Thank you
Rosie
Sami Shamma  @Reply  
             
2 years ago
Hi Rosie.

You are going to need two queries. The first query will link the required tables and produce all the records that match your criteria, with the individual three values that you want to total later. Then, you feed this query into an aggregate query in which you will get the sum for those three fields that contain your values.
Rose Lavoie OP  @Reply  
  
2 years ago
I have a query already that totals the Manual Hours, CNC Hours and Wire Hours via a TOTAL Row at the bottom. This is called Scheduled HRS - FINAL. I need to pull each of those totals based on what still falls within a range: Previous Month, Current Month and Next Month.

I can't seem to figure out the right expression to write into my query.
Sami Shamma  @Reply  
             
2 years ago
so you want three rows with row headings : LastMonth, CurrentMonth, and nextMonth.
and three columns with headings Manual Hours, Wire Hours, CNC Hours.

If so, you need a crosstab query for that.
Crosstab
Rose Lavoie OP  @Reply  
  
2 years ago
I don't even know why I didn't think of using that query...I'll give it a try. Thank you
Sami Shamma  @Reply  
             
2 years ago
It is straight forward, if you run into a problem, just let me know.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 7:45:59 AM. PLT: 1s