Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Seminars   Templates   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > Help > DevNet >
Access Developer Network


Back to Access Developer Network
 

report Total Upload Images   Link  
Brian Dunn 
4 months 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
4 months 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
4 months 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
4 months ago

Brian Dunn
4 months 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
4 months 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
4 months 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
3 months 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
3 months ago
Hello Brian, I've emailed you.
Brian Dunn
3 months 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, below.
 


Back to Access Developer Network Comments
 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to Access Developer Network
Get notifications when this page is updated
 
 
 
 

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
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

Blog RSS Feed    Twitter

YouTube Channel    LinkedIn
Copyright 2023 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 6/10/2023 3:46:08 AM.