GroupFooter values double on report after Print Preview

D

Dean Slindee

I have added the code below to a report. When viewing the report in Print
Preview mode, the group footer totals are correct. However, when the report
is actually printed, the group footer total values *double* in value.


Is this a bug in the Access Print Preview process (an extra cycle)? Or
should the code below be placed in a different event?


As a workaround, is there a way to prevent the report from showing in Print
Preview, by just running it directly to the printer? If I, as the
developer, right click on the report name and choose "Print" from the
context menu, the group totals print correctly. In contrast, I want the user
to click a report menu button, not see the Print Preview, and have the
report print directly.

Thanks,

Dean Slindee



Dim intBondSavedDays As Integer

Dim intCSSavedDays As Integer

Dim intDayReportingSavedDays As Integer

Dim intDOCSavedDays As Integer

Dim intEMPSavedDays As Integer

Dim intOWISavedDays As Integer

Dim intGrandSavedDays As Integer



Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

Dim dtmEndDate As Date

Dim dtmStartDate As Date



'calculate days saved by program

'determine enddate for calc

If IsNull(EndDate) Then

dtmEndDate = ToDate 'report parameter

Else

dtmEndDate = EndDate 'report parameter

End If



'determine startdate for calc

If StartDate < FromDate Then

dtmStartDate = FromDate

Else

dtmStartDate = StartDate

End If



'calc days saved

txtSavedDays = 0

If dtmEndDate >= dtmStartDate Then

txtSavedDays = DateDiff("d", dtmStartDate, dtmEndDate) + 1

End If



'calculate days saved by program

If txtSavedDays <> 0 Then

Select Case ProgramID

Case "Bond"

intBondSavedDays = intBondSavedDays + txtSavedDays

Case "CS"

intCSSavedDays = intCSSavedDays + txtSavedDays

Case "Day Reporting"

intDayReportingSavedDays = intDayReportingSavedDays +
txtSavedDays

Case "DOC"

intDOCSavedDays = intDOCSavedDays + txtSavedDays

Case "EMP"

intEMPSavedDays = intEMPSavedDays + txtSavedDays

Case "OWI"

intOWISavedDays = intOWISavedDays + txtSavedDays

End Select

End If

End Sub



Private Sub GroupFooter0_Print(Cancel As Integer, PrintCount As Integer)

txtGroupSavedDays = 0

Select Case ProgramID

Case "Bond"

txtGroupSavedDays = intBondSavedDays

intGrandSavedDays = intGrandSavedDays + intBondSavedDays

Case "CS"

txtGroupSavedDays = intCSSavedDays

intGrandSavedDays = intGrandSavedDays + intCSSavedDays

Case "Day Reporting"

txtGroupSavedDays = intDayReportingSavedDays

intGrandSavedDays = intGrandSavedDays + intDayReportingSavedDays

Case "DOC"

txtGroupSavedDays = intDOCSavedDays

intGrandSavedDays = intGrandSavedDays + intDOCSavedDays

Case "EMP"

txtGroupSavedDays = intEMPSavedDays

intGrandSavedDays = intGrandSavedDays + intEMPSavedDays

Case "OWI"

txtGroupSavedDays = intOWISavedDays

intGrandSavedDays = intGrandSavedDays + intOWISavedDays

End Select

End Sub



Private Sub ReportFooter_Print(Cancel As Integer, PrintCount As Integer)

txtGrandSavedDays = intGrandSavedDays

End Sub
 
D

Duane Hookom

I would not attempt to use code like this. I think you could do the same
with expressions in control sources or subreports or other. Code is rarely
necessary.

I think someone could help you with the expressions if you described your
data records and calculations.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top