Need help with the "dsum" function.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Background:
What I am trying to do is calculate a total for a field in a query that
meets the criteria set by the criteria argument of the dsum funtion. The
criteria is that the value of the field is only to be summed when the
production date equals the date entered on the form.

Error Message:
Syntax error (missing operator) in query expression '[JobStartDate]='

Details:
Query name: qryApplesKgUsed
Query field name: JobStartDate
Query field to be totaled: KgIssued
Form name: frmDailyProduction
Form field name: txtProductionDate
Syntax of funtion: =DSum("[KgIssued]","[qryApplesKgUsed]","[JobStartDate]="
& [Forms]![frmDailyProduction]![txtProductionDate])

If any one can help me I would greatly appreciate it.

Thanks,
FatMan
 
Error Message:
Syntax error (missing operator) in query expression '[JobStartDate]='

Details:
Query name: qryApplesKgUsed
Query field name: JobStartDate
Query field to be totaled: KgIssued
Form name: frmDailyProduction
Form field name: txtProductionDate
Syntax of funtion: =DSum("[KgIssued]","[qryApplesKgUsed]","[JobStartDate]="
& [Forms]![frmDailyProduction]![txtProductionDate])

If any one can help me I would greatly appreciate it.

If [Forms]![frmDailyProduction]![txtProductionDate] is null, you'd get that error.
Also, if [JobStartDate] is a Date field, you have to do this:

=DSum("[KgIssued]","[qryApplesKgUsed]","[JobStartDate]=#" &
[Forms]![frmDailyProduction]![txtProductionDate] & "#")

Tom Lake
 
Tom:
Thanks. Putting the "#" around the control "txtProductionDate" worked as it
is a date field. Didn't know that you needed to put the "#" around controls
defined as a date fields but should have since access automatically adds them
in the querry by example grid. Dough!!!!

Thanks,
FatMan

Tom Lake said:
Error Message:
Syntax error (missing operator) in query expression '[JobStartDate]='

Details:
Query name: qryApplesKgUsed
Query field name: JobStartDate
Query field to be totaled: KgIssued
Form name: frmDailyProduction
Form field name: txtProductionDate
Syntax of funtion: =DSum("[KgIssued]","[qryApplesKgUsed]","[JobStartDate]="
& [Forms]![frmDailyProduction]![txtProductionDate])

If any one can help me I would greatly appreciate it.

If [Forms]![frmDailyProduction]![txtProductionDate] is null, you'd get that error.
Also, if [JobStartDate] is a Date field, you have to do this:

=DSum("[KgIssued]","[qryApplesKgUsed]","[JobStartDate]=#" &
[Forms]![frmDailyProduction]![txtProductionDate] & "#")

Tom Lake
 
Back
Top