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 
Global DSUM Function
Musoke Herbert 
   
2 years ago
Hello Members, How can i Create a Global Dsum function that Has four Criterias, Am using a four Criteria Dsum Function in a Query but My Data Base is Becoming Slow, can some one make me a global function in a module such that i Can Call the Function in A query. I will Appreciate.

This is What am Using Now
Sumpaid: DSum("Schoolfees","PaymentQ","Pupilname ='" & [Pupilname] & "' AND PayCode ='" & [PayCode] & "' AND Term ='" & [Term] & "' AND YearDatemade =" & [YearDatemade] & "")
Adam Schwanz  @Reply  
           
2 years ago
So you're using a DSUM inside the query now, and you want to make a DSUM function to do the same thing and use the same way in the query? Unless you're applying it to less records or something, that's still doing the same thing, calculating a value for every record.

If you want to look at speed problems, you could try to reduce the amount of records that it needs to run on, or look into any queries that are part of that DSUM, like PaymentQ if it has DLookup/DSum/etc functions in it that you don't need, you may be better off making a new query that omits those fields so it doesn't have to calculate them.
Richard Rost  @Reply  
          
2 years ago
If your DSum is slow, it could be how your query is built. You might be faster going straight to the tables. I actually have a video on this coming out soon. Stay tuned.
Musoke Herbert OP  @Reply  
   
2 years ago
Yes am tuned, waiting for that help
Musoke Herbert OP  @Reply  
   
2 years ago
Thanks Adam, actually am a database developer in my company specializing in access, I have a customer who has used her database for 7 years now, and the slowness in her school database has began to surface, now that an developing a better version of the same , I would like to make it better than , than being used by such clients. Thanks
Kevin Yip  @Reply  
     
2 years ago
A query should use Sum(), not DSum() (or Count, not DCount, and so forth), especially when the tables have lots of rows, which is likely why you see the slowdown.  Sum() is made specially for queries and performs well even if it is evaluated repeatedly.  E.g.:

     SELECT Sum(Field1) FROM Table1 GROUP BY SomeID;

Even if the query above returns a million rows and Sum() is calculated a million times, the query will still be fast.

But if you try to run DSum() a million times with this:

     SELECT DSum("a", "b", "c") FROM Table1;

It will be slow to a crawl.  DSum() is essentially a separate query of its own, so it's like running a million queries at once, hence the slowdown.

DSum() should only be used once or twice, in a form footer or report footer or something, not hundreds or thousands of times in a query.
Kevin Yip  @Reply  
     
2 years ago
Your queries need to be rewritten to have all the DSum, the reason of your slowdown, removed.  There is no better function to replace it with, except Sum().  But to use Sum(), all your queries will have to be rewritten as aggregate queries.
Musoke Herbert OP  @Reply  
   
2 years ago
Thanks Kevin

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:21:27 AM. PLT: 7s