Stepping through the following code in debug, the two variables intHourWorked and intHeadCount do correctly accumulate the values I need. However, when I get to the lines where I try to plug the values into the respective controls on the report, I get a run-time error ‘2448’ (You can’t assign a value to this object) grrrrrr,
What is the correct method of assigning a value?
Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)
Dim rs As Recordset
Dim dbs As Database
Dim strSQL As String
Dim intHeadCount, intHourWorked As Long
Set dbs = CurrentDb()
strSQL = “SELECT DISTINCT tblYearEnd.fkID, tblYearEnd.intYrTtlHours, ” & _
“tblYearEnd.intYrHdCount FROM tblYearEnd;”
Set rs = dbs.OpenRecordset(strSQL, dbOpenSnapshot)
intHeadCount = 0
intHourWorked = 0
Do While Not rs.EOF
‘ intYrTtlHours is Total Hours worked for a specific ID
intHourWorked = intHourWorked + rs!intYrTtlHours
‘ intYrHdCount is Head count for a specific ID
intHeadCount = intHeadCount + rs!intYrHdCount
rs.MoveNext
Loop
‘ txtGTtlHoursWorked and txtGTtlNoEmployees are fields in the report footer
txtGTtlHoursWorked = intHourWorked
txtGTtlNoEmployees = intHeadCount
End Sub
Any help is greatly appreciated.
TIA,
Ken