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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing values on the main report to those on the subreport

Status
Not open for further replies.

jewilson2

Technical User
Feb 7, 2002
71
US
I have a report that pulls data from 2 different tables. The join is left outer because I want to see every record in the base table, and only records that match from the other table. This worked fine until I had to add selection criteria on the second table...which of course kills the left outer join and only returns those records for which the selection formula can be qualified (meaning it exists in the second table).

To get around this, I added the second table as a subreport. This works fine, except now I need to compare values from the first report to those in the subreport (IE if table1.field1 <> table2.field1, then return "false"). Is there a way to execute this kind of logic from one report to the other?

 
You're probably better served to post:

Crystal version
Database used
Example data
Expected output

Then request assistance with the requirements, rather than stating how we must do it, such as using a subreport.

Anyway, you can use shared variables in the details section of each report to pass values on the row level.

Right click the main report details section and select insert section below.

Right click the upper detail section (a) and select suppress

Create a formula for that upper detail section (a) of:

whileprintingrecords;
shared stringvar MyString:= "";

In the subreport detail section create a formula of:

whileprintingrecords;
shared stringvar MyString := {table.field};

Now back in the main report's second details section (b) create a formula such as:

whileprintingrecords;
shared stringvar MyString;
if MyString = {table.field} then
"Yep, they match"
else
"Nope, different"

There's the basics.

Since you didn't post examples of the data, nor the output required, it's difficult to precisely assist you, hopefully this solves the theory aspect.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top