Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Shared variables from subreport... Post Reply Post New Topic
Author Message
rbmauderAF
Newbie
Newbie
Avatar

Joined: 17 Aug 2012
Online Status: Offline
Posts: 2
Quote rbmauderAF Replybullet Topic: Shared variables from subreport...
     Posted: 17 Aug 2012 at 11:34am

I see a lot of posts about shared variables but nothing I have run across seems to match exactly what I am trying to do.

I work for an animal shelter and we track the intakes and outcomes of the animals.  We have an Intake Type and Intake Subtype field in the same table (kennel.)  What I've been asked to do sounds simple but I can't seem to figure out how.

The main report is set up to isolate any animal which falls within the Select statement.  That is done.  Then I take the animal ID field into a sub-report via the Sub-report link box.  The sub-report then looks through the entire kennel table for any record which has a matching animal ID in it.  This data is put in the sub-report's header and sorted so that only the earliest kennel record is displayed on the report.

I need to take the Intake Subtype of the earliest kennel record (the one which is displayed on the report) back to the main report and then (once all of the animals have been processed) to use this information in a crosstab in the main report.  Which record's information will the shared variable have in it when it goes back to the main report?  The first kennel record it processed or the last?  Also, how do I store the shared variable's value between records in the main report since the shared variable is re-initialized each time it chains to the sub-report?

Tongue
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 17 Aug 2012 at 11:42am
I do not think you will be able to do what you want using a sub report.
I am not sure why you are using a subreport
IMO - I try to avoid them whenever possible.
Why not just join the kennel table to itself in the main report or write a command to get your grouped min value from the kennel table and then join that back to the main kennel instance?
IP IP Logged
rbmauderAF
Newbie
Newbie
Avatar

Joined: 17 Aug 2012
Online Status: Offline
Posts: 2
Quote rbmauderAF Replybullet Posted: 17 Aug 2012 at 12:16pm
The kennel table is already joined to itself as an alias called 'returned'.  The Select statement in the main report is:
({returned.intake_type} = "RETURN" and
{returned.intake_date} in {?Begin} to {?End})
and
({kennel.outcome_date} in {?Begin} to {?End} and
{kennel.outcome_type}="ADOPTION")
and
{animal.animal_type}={?AnimalTypeToConsiderForReport}

Although I have seen command statements, I've never written one.  Can you have both tables and a command in Database Expert?  How do they relate one another?


IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum