G
Guest
I have a text box in a report header where I need to use dsum because the I
need the sum of fields in a table that is not the recordsource of the report.
I've hit errors or undesired results no matter what I've tried.
From code (rpt header format), if the first record in the table matches the
criteria, it returns the sum of all records. If the first record doesn't
match the criteria, it returns nothing.
Me.Text127.ControlSource =
"=DSum('[CostPerPaycheck]','tblSavingsFunds',[fundstatus] = 'Waiting')"
From code (rpt header format), when attempting to print prevew, this gives
error 2434, "the expression you entered contains invalid syntax" (added '
around criteria)
Me.Text127.ControlSource =
"=DSum('[CostPerPaycheck]','tblSavingsFunds','[fundstatus] = 'waiting'')"
This works when entered directly into the textbox:
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting'")
but I can't get it to work with another necessary criteria that contains a
date variable (the variable works perfectly behind the form in some
"me.textbox.controlsource=" statements)
When keyed directly into the text box and combined with the date variable
(nextpayday) this returns #Error
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and
[savingsperiodenddate] > nextpayday")
When keyed directly into the text box, these automatically add brackets
around nextpayday and then prompt for a value for nextpayday when attempting
print preview;
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and
[savingsperiodenddate] > #" & [nextpayday] & "#")
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and #"
& [savingsperiodenddate] & "# > #" & [nextpayday] & "#")
I'm stumped. I've searched an can't find anything. All help is
appreciated. Thank you.
need the sum of fields in a table that is not the recordsource of the report.
I've hit errors or undesired results no matter what I've tried.
From code (rpt header format), if the first record in the table matches the
criteria, it returns the sum of all records. If the first record doesn't
match the criteria, it returns nothing.
Me.Text127.ControlSource =
"=DSum('[CostPerPaycheck]','tblSavingsFunds',[fundstatus] = 'Waiting')"
From code (rpt header format), when attempting to print prevew, this gives
error 2434, "the expression you entered contains invalid syntax" (added '
around criteria)
Me.Text127.ControlSource =
"=DSum('[CostPerPaycheck]','tblSavingsFunds','[fundstatus] = 'waiting'')"
This works when entered directly into the textbox:
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting'")
but I can't get it to work with another necessary criteria that contains a
date variable (the variable works perfectly behind the form in some
"me.textbox.controlsource=" statements)
When keyed directly into the text box and combined with the date variable
(nextpayday) this returns #Error
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and
[savingsperiodenddate] > nextpayday")
When keyed directly into the text box, these automatically add brackets
around nextpayday and then prompt for a value for nextpayday when attempting
print preview;
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and
[savingsperiodenddate] > #" & [nextpayday] & "#")
=DSum("[CostPerPaycheck]","tblSavingsFunds","[fundstatus] = 'waiting' and #"
& [savingsperiodenddate] & "# > #" & [nextpayday] & "#")
I'm stumped. I've searched an can't find anything. All help is
appreciated. Thank you.