If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Crystal Reports > Unable to Reset Shared Variables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On