DSum giving me a headache

CarlRostron

Registered User.
Local time
Today, 23:09
Joined
Nov 14, 2011
Messages
88
I am trying to sum up the hours worked field in my subform, I have tried different DSum functions but I can't get it to work. Attached is an image of the form I am trying to sum and place into the text box.

This is what I have tried:
Code:
=DSum([HoursRecorded],"tblTimesheet",[qryTimesheetByClient subform]![ClientID]=[tblTimesheet].[HoursRecorded])

Code:
=DSum([HoursRecorded],"qryTimesheetByClient",[qryTimesheetByClient subform]![ClientID]=[tblTimesheet].[HoursRecorded])
 

Attachments

  • Image.jpg
    Image.jpg
    94.3 KB · Views: 93
  • Image 2.jpg
    Image 2.jpg
    101.7 KB · Views: 86
You need to check what is used for what.

DSUM is a domain function, that can sum stuff from a "domain" - that is overkill in this case.
To refer to stuff on a subform correctly, the fastest way is to make a text box on a form, and in the ControlSource press the three ellipses and choose the Expression Builder, and navigate to the subforms' contol in question. That way you get the syntax right. (and then delete the textbox)

As to your problem, you should use =Sum(YourField) as ControlSource of a textbox on the subform's footer or header.

Then on the main form, make that textbox the ControlSource of your HoursWorked textbox.
 
Thanks for your message. I have done as you said. Made a SUM(HoursWorked) Textbox in the footer of the subform. i have tested this (and apart from the format) it is giving an output into the textbox.

I have also created a second textbox on the main form, and in the control source, set that to what is in the subform text box (as created above). However this textbox is showing blank? I have a Me.Requery code running on changing my combo button so i would have thought the requery would update everything ok unless I am amiss on something else?
 
Blank? No way Jose :) Either the Control Source is not set right (so try the navigation thingy) or there is garbage in the summing textbox on the subform.
 
I think I was referencing the TextBox Handle rather than the TextBox which contained the summed value and was probably the reason why it was blank. Anyway, done that now and all working. Cheers for the help.
 

Users who are viewing this thread

Back
Top Bottom