Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Help > DevNet >
Back to Access Developer Network    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
report Total
Brian Dunn 
     
2 years ago
Report running total,
How do I modified this to run for 12 Months please from April to April? I have been trying for 2 months
It runs for April to 31 December ever week with total then start again on 1 Jan with new total
From Text box
=DSum("PaySkipper","SkipperPayQ","InvoiceDate>=# 1/1/" & Year([InvoiceDate]) & "# and InvoiceDate <=#" & Format([InvoiceDate],"mm/dd/yyyy") & "# and SkipperID=" & [SkipperID] & " and CatchXProductID<=" & [CatchXProductID])
Kevin Yip  @Reply  
     
2 years ago
This is admittedly not a trivial task, and you may have to do this with some tricky VBA.  Since this is a report, VBA can be used.  VBA lets you store a running total in a variable, which you can't do with DSum().  You can have the VBA code check if the current date and the previous date belong to the same 12-month period.  If they do, add the current value to the running total.  If they don't, set the running total to zero.

It is a tricky task in itself to check if two dates fall inside the same period from 5/1 of one year to 4/30 of the next.  For instance:

Previous date: 12/31/2022, $123.00
Current date: 2/22/2023, $456.00
Both dates are in the same 12-month period of 5/1/2022-4/30/2023, so running total is $123 + $456 = $579.00.

Previous date: 4/3/2021, $123.00
Current date: 5/22/2021, $456.00
The two dates are in different 12-month periods: 4/3/2021 is in the period of 5/1/2020-4/30/2021, and 5/22/2021 is in the period of 5/1/2021-4/30/2022; so the running total is just $456.00 as of 5/22/2021.

So your key task is to figure out what 12-month period each date falls into.

For every date, you need to figure out the start and end date of the 12-month period it is in.  Do this for both the previous date and current date.  

If the start and end dates don't exactly match, then the previous date belongs to an older 12-month period, and its amount should not be added to the running total.

The resulting VBA code is not terribly complex, but has some tricky logic as described above.  I don't know if you have taken any VBA courses yet, so I'm hesitant to post sample code.  

If other posters know any other way to do this (with or without VBA) that is less unwieldy than the above, please post.
Kevin Yip  @Reply  
     
2 years ago
I'm showing you my sample VBA code anyway.  Richard doesn't want beginner students to run before they can walk, but I want to at least show you what running looks like.  See pictures below.
Kevin Yip  @Reply  
     
2 years ago

Brian Dunn OP  @Reply  
     
2 years ago
Thank you Kevin, I have a little knowledge on VBA, I though what I sent, needed to change to Dateserial is that possible? I been waiting for Adam Schwanz to correct bug since start of Jan, as was commissioned to build it, on Richards guidance.
I have posted 22 days a to showing pics, it was all doing what I need till, if you have time please take a look at them.
Best Regards Brian
Kevin Yip  @Reply  
     
2 years ago
Hi Brian, I didn't know Adam was helping you with this.  If you commissioned him to do this (and if payment is involved), then I would very much like to defer to him.  He may have a better understanding of your situation than I do.  If you are still at beginner's level as your badge indicates, you may also consider spending money on more training on Access, such as the courses here.
Brian Dunn OP  @Reply  
     
2 years ago
Hi Kevin, i thought was only fair to tell you, Adam had made it for me, Adam told me he would put it right, 2 months ago, and still has not, I am working though courses on here.
Thank you again Kevin/
Brian
Brian Dunn OP  @Reply  
     
2 years ago
Kevin I prepared to pay for you to have a look DB, if you would help? Do I need to ask Richard first? Adam will not reply to me,
Brian
Adam Schwanz  @Reply  
            
2 years ago
Hello Brian, I've emailed you.
Brian Dunn OP  @Reply  
     
2 years ago
Yes I have replied, thank you, I still have no running total on the report, only on amount that week, not the total for year, only from  April  
This works but only run dec 31 last year then starts a new total 1st Jan

=DSum("PaySkipper","SkipperPayQ","InvoiceDate>=# 4/14/" & Year([InvoiceDate]) & "# and InvoiceDate <=#" & Format([InvoiceDate],"mm/dd/yyyy") & "# and SkipperID=" & [SkipperID] & " and CatchXProductID<=" & [CatchXProductID])

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

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/21/2025 7:03:32 PM. PLT: 1s