Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shared Variables duplicating sometimes

Status
Not open for further replies.

PAULCALLAGHAN

Technical User
Sep 4, 2001
165
CA
I'm using Crystal 8.5 with a pervasive database.

I know I'm using shared variables properly because I have carefully checked my results manually. However, I'm getting a duplication type problem when the linked field value is not always a pefect match.

The main report is based on the Part Master file. The subreport is based on the transaction history file, which may not contain all parts from the Part Master file. The link is part number.

When the same part number exists in both files (i.e main report and sub-report), everything is fine. The shared variable works right.

However, when the part number from the Part Master does not exist in the transaction history file the shared variable result uses the previous part number result. The shared variable is then duplicated from the last (valid) shared variable result. Why? How can I correct this?
 
Put a formula at the end of the part number group, that clears the shared variable.

whileprintingrecords;
shared numbervar myvar :=0;

Or in the subreport, where the shared value is setup, check for
if isnull(secondtable.partnumber)=true then
shared numbervar myvar :=0
else shared numbervar myvar = set the value
 
Thanks MColeman, that worked.

That is, I used the second of your two approaches and I don't get the duplication anymore! Nice work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top