Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2004
    Posts
    21

    Angry Unanswered: Shared Variables

    I am trying to share a variable from a subreport back to the main report. I have the formauls set up as follows:

    In the Sub-Report

    Shared numberVar EmployeeCount;

    EmployeeCount := DistinctCount({EMPS.EMPNO})

    In the Main Report

    Shared numberVar EmployeeCount

    The formula gives me the correct value in the subreport, but when I but the field into the main report, it comes out as zero. Am I doing something wrong? Any help would be greatly appreciated!

  2. #2
    Join Date
    Dec 2004
    Location
    Connecticut
    Posts
    85

    Post

    The two things that usually cause the shared data to show up as "0" in the main report are

    1- the syntax of the formula definintion (those semicolons are important)

    and

    2- the placement of the field (it must be evaluated after the subreport).

    The kb article explaining the use of shared variables (http://support.businessobjects.com/l...s/c2007600.asp) will explain what I mean. I keep a copy for handy reference whenever I'm using shared variables.

  3. #3
    Join Date
    Apr 2004
    Posts
    21
    Ok I made sure that the semicolons are in the right place. Now I did place the subreport in Details (a) section and then then shared variable in the Details(b) section. This way the Subreport is ran before the main reort. It still brings back zeros. I move the shared variable to the report footer well after the subreport and still zeros. Any other suggestions?

    Thanks for all of your help!

  4. #4
    Join Date
    Dec 2004
    Location
    Connecticut
    Posts
    85
    The syntax has to match exactly. Sometimes it takes me three or four tries to get it right. Which is why I keep the cheat sheet handy.

    The formula in the main report should have three lines - 1 tells it when to evaluate the formula, 2 tells it which variable to share and what kind of variable it is and 3 tells it what the value of the variable is. The following example works in CR v7-9:

    WhilePrintingRecords;
    Shared NumberVar EmployeeCount;
    EmployeeCount


    If the subreport shows the correct number in the shared field, and the syntax is correct there must be some condition telling the report not to evaluate the field in the main report. Make sure that the section it's in isn't hidden or suppressed and that the field itself isn't conditionally hidden or suppressed.

Posting Permissions

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