lawsonbooth
03-30-2010, 07:07 AM
I have a report where I have to track some totals which have calculation criteria to complex for me to handle with “IIF” statements in the print controls so I use VBA to perform the calculations. The report works fine until it gets to the last page of the report. The last section totals and report grand totals are wrong. I have been researching the posts and reading everything I can find on the PrintEvent and I think it has something to do with the way Access backs up to format a page. I am totally baffled. :banghead: Any help to get the last page to print correctly would be greatly appreciated. I can not post the database because it contains sensitive company data.
I am using Access'97 on a Windows XP platform.
Here are the various code sections from the report:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
[tbSavedYrPrem] = 0
xDateItems = xDateItems + 1
xEmpItems = xEmpItems + 1
'ignore 000 & 045
If [tbDispositionCode] <> "000" And _
[tbDispositionCode] <> "045" Then
'count completes
If [tbTaskStatus] = "Completed" Then
xDateCount = xDateCount + 1
xEmpCount = xEmpCount + 1
End If
'count saved
If ([tbDispositionCode] >= "001" And _
[tbDispositionCode] <= "033") Or _
([tbDispositionCode] = "046") Then
'detail
[tbSavedYrPrem] = [xYrPrem]
'accum date level
xDateSaved = xDateSaved + Nz([xYrPrem])
'accum emp level
xEmpSaved = xEmpSaved + Nz([xYrPrem])
End If
End If
End If
End Sub
Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
'emp level
'[tbEmpItems] = xEmpItems
[tbEmpCount] = xEmpCount
[tbEmpSaved] = xEmpSaved
xEmpItems = 0
xEmpCount = 0
xEmpSaved = 0
End If
End Sub
Private Sub GroupFooter3_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
'date level
[tbDateSaved] = xDateSaved
[tbDateCount] = xDateCount
'[tbDateItems] = xDateItems
xDateCount = 0
xDateSaved = 0
xDateItems = 0
End If
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
xDateCount = 0
xDateSaved = 0
xDateItems = 0
xEmpItems = 0
xEmpCount = 0
xEmpSaved = 0
End Sub
I am using Access'97 on a Windows XP platform.
Here are the various code sections from the report:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
[tbSavedYrPrem] = 0
xDateItems = xDateItems + 1
xEmpItems = xEmpItems + 1
'ignore 000 & 045
If [tbDispositionCode] <> "000" And _
[tbDispositionCode] <> "045" Then
'count completes
If [tbTaskStatus] = "Completed" Then
xDateCount = xDateCount + 1
xEmpCount = xEmpCount + 1
End If
'count saved
If ([tbDispositionCode] >= "001" And _
[tbDispositionCode] <= "033") Or _
([tbDispositionCode] = "046") Then
'detail
[tbSavedYrPrem] = [xYrPrem]
'accum date level
xDateSaved = xDateSaved + Nz([xYrPrem])
'accum emp level
xEmpSaved = xEmpSaved + Nz([xYrPrem])
End If
End If
End If
End Sub
Private Sub GroupFooter1_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
'emp level
'[tbEmpItems] = xEmpItems
[tbEmpCount] = xEmpCount
[tbEmpSaved] = xEmpSaved
xEmpItems = 0
xEmpCount = 0
xEmpSaved = 0
End If
End Sub
Private Sub GroupFooter3_Print(Cancel As Integer, PrintCount As Integer)
If PrintCount = 1 Then
'date level
[tbDateSaved] = xDateSaved
[tbDateCount] = xDateCount
'[tbDateItems] = xDateItems
xDateCount = 0
xDateSaved = 0
xDateItems = 0
End If
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
xDateCount = 0
xDateSaved = 0
xDateItems = 0
xEmpItems = 0
xEmpCount = 0
xEmpSaved = 0
End Sub