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 
Issue with DSum
Walter Hamilton 
    
4 years ago
I have a table named tbl_Direct_Indirect_Hours that contains the number of hours an employee bills to DirectHours and IndirectHours for a specified pay period.  I'm trying to build a query that totals the number of hours billed by each employee.  I'm trying to use DSum but I keep getting an error.  

My expression is:

Direct Labor: DSum("DirectHours","qry_EmployeeHours","Contacts_ID=" & [Contacts_ID])

Indirect Labor: DSum("IndirectHours","qry_EmployeeHours","Contacts_ID=" & [Contacts_ID])

Do I need to conver DirectHours and IndirectHours using CDbl  inside the expression?

What am I doing wrong?
Adam Schwanz  @Reply  
           
4 years ago
Couple possibilities, what is qry_EmployeeHours? If you're trying to DSUM from the table, you should use the table there.

DSum("DirectHours","tbl_Direct_Indirect_hours","Contacts_ID=" & [Contacts_ID])

Other possibility, is contacts_ID a number or a string?
Adam Schwanz  @Reply  
           
4 years ago
You're also going to need to add to the criteria a date range if you want to only get the hours for a period.
Adam Schwanz  @Reply  
           
4 years ago
Also if that solution doesn't fix it. Let me know what the error says :P
Walter Hamilton OP  @Reply  
    
4 years ago
Adam - Contacts_ID is a Number.  I tried the formula you recommended and I don't get any value returned.  I'm not getting the error anymore but all the cells are blank.  I'm just trying to get this first portion to work before I calculate by date range.  We are ultimately looking to build a report that shows hours available for each employee and the number of hours they've billed towards Direct and Indirect.
Adam Schwanz  @Reply  
           
4 years ago
Can I see a picture of your query? That would clear up some things. Snip & Sketch
Walter Hamilton OP  @Reply  
    
4 years ago

Adam Schwanz  @Reply  
           
4 years ago
Can I see the top part too? Interested in how many tables you're bringing in and the joins.

If nothing pops out we can just change the query to use the SUM aggregate function instead.
Walter Hamilton OP  @Reply  
    
4 years ago
I just realized why I'm not getting any values from the updated formula.  tbl_Direct_Indirect_hours doesn't have Contacts_ID in it.  I'm importing that from an excel spreadsheet that is exported from a different program.  That's why I was trying to use qry_EmployeeHours initially.  I actually got it to work using

Direct Labor: DSum("DirectHours","qry_EmployeeHours","Contacts_ID=" & [Contacts_ID])
Indirect Labor: DSum("IndirectHours","qry_EmployeeHours","Contacts_ID=" & [Contacts_ID])

I'll continue to work on this.  Not sure how I want to break it out beyond this point.

Adam Schwanz  @Reply  
           
4 years ago
That will do it, so its working now again using the original expression?

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:17:11 AM. PLT: 0s