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 Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
DSUM DateSerial Month To Date
Dan Jackson 
            
4 years ago
Running the following in VBA is pulling the whole year when it should be calcualting just this month. I note that the resulting figure for this month is 0 so far but am i missing something?

Nz(DSum("CommRecAMT", "SalesAllQ", "StatementDate>=#" & DateSerial(Year(Date), Month(Date), 1) & "# And AdvisorID = 6"), 0)

Even if i replace ~ Month(), ~ with a specific number, its still calculating the whole year

Thank You
Alex Hedley  @Reply  
           
4 years ago
Make the value of the DateSerial it's own variable
Print it
Pass it into the DSUM
Dan Jackson OP  @Reply  
            
4 years ago
Sorry Alex, I still have a loooooooong way to go. Baby steps? Thanks
Kevin Robertson  @Reply  
           
4 years ago
I tested your DSum function and it worked perfectly for me.

- Is there anything in the query preventing the function from working correctly?
- It may be another date format problem.
Dan Jackson OP  @Reply  
            
4 years ago
Bizaar. Looking at it makes sense but yeah, the following shows what i've tried to do and how its worked.

Again, the YTD looks perfect but doing MTD or TODAY doesn't work. I've printed the date function used underneath
Form (Pic 1)
Code (Pic 2)

- The Query is a Union Query, Pic (3)
- The Text Box on the Form has been set as Currency with 0 Decimal Places in properties


Dan Jackson OP  @Reply  
            
4 years ago

Dan Jackson OP  @Reply  
            
4 years ago

Dan Jackson OP  @Reply  
            
4 years ago

Dan Jackson OP  @Reply  
            
4 years ago
Still having an issue with this one. As you can see from 3 pics up, the date function is working, pulling the correct date. But when used in my DSUM (2 Pics Up), its having the wrong affect - Today is generating nothing and Month To Date is pulling year to date.

No error messages and compile brings nothing up. I'm really trying to avoid using queries so i don't get caught up but i might have to revert to them for the Today and Month figures if i can't work this out.

Does anyone have any ideas?
Kevin Robertson  @Reply  
           
4 years ago
Dan,

Try wrapping the DateSerial function in the Format function (US format).

Format(DateSerial(Year(Date), Month(Date), 1), "mm/dd/yyyy")
Dan Jackson OP  @Reply  
            
4 years ago
Getting there, Getting There!
Got the Today working but Month to Date still isn't

Text_WMTDCIMS = DSum("GrossWrittenAMT", "SalesAllQ", "GrossWrittenDate>=#" & Format(DateSerial(Year(Date), Month(Date), 1), "dd/mm/yyyy") & "# And AdvisorID = 3")
Dan Jackson OP  @Reply  
            
4 years ago

Kevin Robertson  @Reply  
           
4 years ago
Change the format to mm/dd/yyyy
Dan Jackson OP  @Reply  
            
4 years ago
Strange! It Works. Guess It didn't matter with the Year to Date...

Thank You Kevin. Just sent a little something to express my gratitude, just wish i could do more. Have a great weekend mate.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access 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/2/2026 7:25:10 AM. PLT: 0s