Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004
    Location
    Ottawa
    Posts
    1

    Exclamation Unable to Reset Shared Variables

    I've created a report in CR Pro V8.5. It contains 3 subreports in 3 different details sections. Each of the subreports contains a subtotal that gets passed back to the main report. The main report prints the grand total in another detail section below the first 3. I'm using shared variables. In some cases, the subreports have no data and therefore, no subtotal. I'm trying to reset the subtotal variables to zero. It's working for one of the subreports (detail section c, DirCost variable), but the other two are keeping the subtotal value from the previous record if they have no values for the current record. Here is the code I'm using (the lines ending in : are not part of the code).

    Main Report:
    GrandTotal variable:
    {@DirCost}+{@LabCost}+{@MatCost}

    DirCost:
    Shared NumberVar DirCost;

    LabCost:
    Shared NumberVar LabCost;

    MatCost:
    Shared NumberVar MatCost;


    Detail Section a--LabCost:
    Shared NumberVar LabCost:=0;
    LabCost:=Sum ({@AICCosts});

    Detail Section b--MatCost:
    Shared NumberVar MatCost:=0;
    MatCost:=Sum ({@AICCosts});

    Detail Section c--DirCost:
    Shared NumberVar DirCost:=0;
    DirCost:=Sum ({@Dollars});

    Thanks in advance.
    lurosco

  2. #2
    Join Date
    Oct 2003
    Posts
    357

    Thumbs up

    Try this
    Code:
    Main Report:
    GrandTotal variable:
    {@DirCost}+{@LabCost}+{@MatCost}
    
    DirCost:
    if NextIsNull ({FieldName}) then
    0
    else
    Shared NumberVar DirCost;
    
    LabCost:
    if NextIsNull ({FieldName}) then
    0
    else
    Shared NumberVar LabCost;
    
    MatCost:
    if NextIsNull ({FieldName}) then
    0
    else
    Shared NumberVar MatCost;
    
    
    Detail Section a--LabCost:
    Shared NumberVar LabCost:=0;
    LabCost:=Sum ({@AICCosts});
    
    Detail Section b--MatCost:
    Shared NumberVar MatCost:=0;
    MatCost:=Sum ({@AICCosts});
    
    Detail Section c--DirCost:
    Shared NumberVar DirCost:=0;
    DirCost:=Sum ({@Dollars});
    Madhivanan

Posting Permissions

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