Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images | @Reply | Bookmark | Link | Email | Next Unseen |
Can you use an if in DSUM
Dan Jackson 
        
4 years ago
Hi!

Looking to DSUM 2 Fields and hoping to choose which field based on the content of one field.

If NetISSUED <=0 Then
     DSUM NetWRITTEN Else
     DSUM NetISSUED

How do i build this into a DSUM So that it'll calculated NetIssued EXCEPT when NetIssued is 0 which it will then use the NetWRITTEN?

Thank You
Dan Jackson OP  @Reply  
        
4 years ago
Just for Clarity, I need the IF INSIDE the DSUM. I have written it the other way around to demonstrate but i don't think will work as i wish to add the figures from either field
Kevin Robertson  @Reply  
          
4 years ago
You could use IIF with DSum.
You could put something like this in the Control Source of an unbound field.

=IIf(Not IsNull([ID]), IIf([NetIssued]<=0, DSum("NetWritten", "TableName"), DSum("NetIssued", "TableName")), 0)

In my example I also check for an ID so the DSum doesn't run on new records.
Dan Jackson OP  @Reply  
        
4 years ago
Thanks. I've removed the IDCheck temporarily while building but is a great idea when all is done.

I'm still getting an error when running this. Also, being that you've put the DSUMs inside of the IFF, will it provide one figure for both fields?

Text_WYTDCIMS = IIf([NetIssuedAMT] <= 0, DSum("NetWrittenAMT", "SalesALLQ"), DSum("NetIssuedAMT", "SalesALLQ"))
Dan Jackson OP  @Reply  
        
4 years ago

Dan Jackson OP  @Reply  
        
4 years ago

Kevin Robertson  @Reply  
          
4 years ago
I am assuming from the error message that your form is unbound. Access has no idea what NetIssuedAMT is. The field will need to be looked up first so you can check if it is 0 or not. DLookup
Dan Jackson OP  @Reply  
        
4 years ago
Found a simpler way around it! Thanks Mate

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

Next Unseen

 
 
What's This?

 

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: 9/30/2026 7:38:37 AM. PLT: 1s