Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Report in acViewPreview Doesn't Match Printout (Ac

    I have a report that displays properly when run from a form that executes:
    DoCmd.OpenReport "rptActual Hours and Shifts Versus Required Hours and Shifts", acViewPreview
    This command is executed in the On Click event of a command button.

    All numbers are perfect when previewing the report. However, when the last page of the report is printed, four fields in the Report Footer (which contains grand totals of 8 columns) are different (higher) than when the report is previewed. These four fields are accumulators which are added to in the Detail Print event of the report.

    Example:
    Dim strwhere As String
    strwhere = "[strShift-type] = 'KOB' and [intShift - Member Num] = " & [intMEMBER_NUM]
    [KOB Shifts] = DCount("[dtShift - Date]", "tblPlacementShift Dates", strwhere)
    totKOB = totKOB + [KOB Shifts]

    totKOB is one of the incorrect fields.

    Does printing the report execute additional code that is not executed when the report is previewed? What is causing this difference and how can I fix this?

    Thanks, in advance.
    Carol W.

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Are you Previewing the report, then printing it.

    Does the same thing happen if you print it without first previewing?


    I have had cases where the accumulators are all double when I Print (after previewing) because the printing process causes all the accumulaotrs to accumulate a second time.

    So you need to reinitilise them.
    Regards
    John



  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report in acViewPreview Doesn't Match Printout (Ac

    The On Print event of the detail section may occur more than once for the same record. Each time the PrintCount argument is incremented by 1. You could try

    If PrintCount = 1 Then
    ' code to increment totals
    ...
    End If

  4. #4
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Yes, normally I preview the report and then print it.

    I just tried printing the final page without previewing it. This is really strange. The numbers on the last page are neither the preview numbers nor the printed numbers. Instead, they are the differences between the numbers when the report is previewed and when it it printed <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    Weird!
    Carol W.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Hans:

    I will try to alter the code as you suggest in a while. I'll report back.

    Thanks.
    Carol W.

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Another option is to use the Retreat Event reverse the Accumulation.
    Regards
    John



  7. #7
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Sorry, Hans. That suggestion didn't work.

    Any other thoughts?
    Carol W.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  9. #9
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    John:

    I tried reversing the accumulation in the retreat event. Unfortunately that didn't work either.

    Any other thoughts?

    Another weird thing -- I tried printing the report to a pdf file and those four accumulators were doubled! Now I'm really confused.
    Carol W.

  10. #10
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    I'd be happy to do that. However, all of the data in several tables is necessary to reproduce the problem. In addition, the tables are linked tables in a separate mdb file. When I embed the tables in the main mdb file, the size is almost 20MB.

    What do you suggest?
    Carol W.

  11. #11
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    I am not sure, but there are two separate issues here.

    1. <LI>On each pass through the report, the accumulators accumulate. Sometimes, it goes back and visits a record more than once. This throws out the totals.
      <LI>When you preview, then print, the whole process occurs twice so your totals are (roughly) double what they should be.
    So to solve the second problem, you need to initialise the accumulator variables in the Print or Format event of the Report.
    Here is a sample from one of my databases.

    <pre>Private Sub ReportHeader_Print(Cancel As Integer, PrintCount As Integer)
    currPurchasesTotal = 0
    currInvoicetotal = 0
    currTotalRefund = 0
    currOutstanding = 0
    End Sub</pre>


    To solve the first use test for printcount =1, or reversing the accumulation in the retreat event.

    For me, a combination of these approaches has solved this problem. I just want to check that you have implemented both, before looking further.
    Regards
    John



  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    You could also try using the On Format event instead of On Print (and test for FormatCount = 1 instead of PrintCount = 1).

  13. #13
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    You could use additional queries to accumulate these totals, then join these queries to you your report query.

  14. #14
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    I have identified the difference in the totals. I created an Excel spreadsheet from the report, added a few sum formulae and saw that the display totals are correct. The problem is that the detail lines on the last page (page 19) are being added into the accumulators twice when the report is printed.

    Any additional thoughts as to why the detail lines on the last page are being handled differently than the other details lines?

    Thanks, in advance. This sure is a mystery, at least to me <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>
    Carol W.

  15. #15
    3 Star Lounger
    Join Date
    Dec 2001
    Location
    Nevada, USA
    Posts
    207
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Report in acViewPreview Doesn't Match Printout

    I implemented both (1) only adding to the accumulators when PrintCount = 1 and (2) subtracting the detail from the accumulators in the Detail Retreat event. I also set a breakpoint on the first line of the Detail Retreat event. It never stops at the breakpoint.

    Thank you for your interest and suggestions.
    Carol W.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •