Skip to Content
avatar image
Former Member

Variable with different value in 2 subreports

Hi

I am editing a report consisting of 1 main report(A) and 2 subreports(B and C) by Crystal Reports 2008 (12.3.0.601), and printing it on server with crystal-report-java-runtime-sdk-12.2.213.1476

(Report A)

Page Header (shared numberVar counter := 0;)

Details a (Report B)

Details b (Report C)

Report Footer

A shared variable Counter is initialized in A and for B and C calling it. Counter is for B and C calculating stuffs during printing, and the result of B is supposed to to be passed to C.

For example,

---Start of B---

step 1) counter := counter + 5; (now counter is 5)

step 2) counter := counter + 3; (now counter is 8)

step 3) counter := 0; (now counter is reset to 0)

step 4) counter := counter + 1; (now counter is 1)

New page

step 5) counter := counter + 10; (now counter is 11)

step 6) counter := counter + 8; (now counter is 19)

---End of B---

(on server) After printing B, the value of Counter is shown as 0, which is supposed to be 19, in C. I tried to rewrite the initialization from (shared numberVar counter := 0;) to (shared numberVar counter;), the value of Counter is then shown as 27.

But there is no above problem if I "Print Preview" in the report editing software, all I get is 19 in C.

I have no idea what is happening (why are there different outcomes of the editing software and java sdk?), please correct me.

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 10, 2017 at 07:31 AM

    Try two things

    1. Make sure all formula evaluating, resetting and displaying start with

    whileprintingrecords;

    2 Move reset to Report header, if report c is on page 2 then counter will be reset in page2 header

    Failing that try using two variables one for each subreport and then add together in report footer

    Ian

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks for your replies anyway, I am resetting the count in the sub reports like,

      Shared numberVar counter;

      Global numberVar currentPage;

      if (currentPage <> PageNumber) then (

      counter := 0;

      currentPage := currentPage + 1;

      )

      but the result of counter I get in the next sub report is likely never reset, but accumulated

      I tried to log the "PageNumber", by something like adding it to an array, and it showed that the values were 1,2,3,4... in that report which is expected, but the values were all 1 in the next sub report by getting the same array. And again, it is normal and achieves what I want in the "Print Preview" of the editing tool, so I just wonder if there is any difference between shared library and the software itself, or is it a bug?