(Sorry, I want to SUM hours by EmpNum.)
I have a table, tmpHours, which contains these fields:
EmpNum, PROCNO, HOURS, Payable
It contains multiple entries per person, per day, or hours worked by Process Number (PROCNO). Some PROCNOs are payable, some are not. Some PROCNOs are special, like for a doctor appointment. Table tmpHours also contains all data for 7 days (1 week). The Payable field is a Yes/No field.
I have a report where I want to sum all the hours, per person for all the records in tmpHours (1 week). However, some Process Numbers are payable, some are not, so I need to use critiera.
On my report I group by EmpNum and show the EmpNum footer with these columns/text boxes for types of pay:
txtEmpNum txtWorked txtDoctor txtFuneral
- Putting a Dsum as the recordsource for txtWorkHours did not work. This is the Dsum I tried:
=Dsum("[PROCHOURS]", "tmpHours", "[Payable]=True")
Is there an easier way to do this, perhaps using VBA in my Group_Format event? I was trying this in my Group_Format event:
Any ideas? Thank you.
I have a table, tmpHours, which contains these fields:
EmpNum, PROCNO, HOURS, Payable
It contains multiple entries per person, per day, or hours worked by Process Number (PROCNO). Some PROCNOs are payable, some are not. Some PROCNOs are special, like for a doctor appointment. Table tmpHours also contains all data for 7 days (1 week). The Payable field is a Yes/No field.
I have a report where I want to sum all the hours, per person for all the records in tmpHours (1 week). However, some Process Numbers are payable, some are not, so I need to use critiera.
On my report I group by EmpNum and show the EmpNum footer with these columns/text boxes for types of pay:
txtEmpNum txtWorked txtDoctor txtFuneral
- Putting a Dsum as the recordsource for txtWorkHours did not work. This is the Dsum I tried:
=Dsum("[PROCHOURS]", "tmpHours", "[Payable]=True")
Is there an easier way to do this, perhaps using VBA in my Group_Format event? I was trying this in my Group_Format event:
txtWorked seem to give the right number, but not txtDoctor. When the code runs for txtDoctor I get an error "Invalid use of null" however the variable crit is not null, it contains the correct string.dim crit as string
dim si as single
' Using table tmpHours:
' Sum hours flagged as Payable for txtWorked for this EMPNO.
crit = ""
crit = "(((tmpHours.EMPNO)='" & txtEmpNum & "') AND ((tmpHours.Payable)=True)) "
si = DSum("[PROCHOURS]", "tmpHours", crit)
txtWorked.Value = si
' Now calc. doctor hours for this person.
crit = ""
crit = "(((tmpHours.EMPNO)='" & txtEmpNum & "') AND ((tmpHours.PROCNO)=3945)) "
si = DSum("[PROCHOURS]", "tmpHours", crit)
txtDoctor.Value = si
Any ideas? Thank you.
Last edited: