×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Compare a field from main report against a field from a subreport on CRYSTAL REPORT

Compare a field from main report against a field from a subreport on CRYSTAL REPORT

Compare a field from main report against a field from a subreport on CRYSTAL REPORT

(OP)
I was wondering if there is a way for comparing a field from the main report against the a field from a subreport.
My main report is pointing to the current month data and the same report is pointing to the previous month data in the sub report.

I need to do something like:
IF SubReportStatus(previous month) = '1-30 days' AND MainReportStatus(Current month) = '31-60 days' THEN "Worse" ELSE IF
IF SubReportStatus(previous month) = '61-90 days' AND MainReportStatus(Current month) = '91+ days' THEN "Worse"

etc etc.

It would be really helpful and really appreciated to know if there's a way this can be done.

Many Thanks

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

You would have to put the value of the shared report field in a shared variable (i.e, in a formula). Then it will be visible in the main reports (in any section after where the sub-report is).

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

(OP)
Hi Kray,

When you say "put the value of the shared report field" what do you mean by that, would you be able to provide an example? I'm fairly new to Crystal so need assistance with formulas.

Please let me when possible as I have been on this project for a while and need to complete soon.

Many Thanks

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

So in a formula you would set up something like this in the sub-report

Shared stringvar somevalue := {field value}; //You could also use the result of another formula. I just used the stringvar as an example. I do not know what data type you want to pass.

In the main report in s section after the where the sub-report is (and do not suppress the section where the sub-report is or it will not execute). Another formula

Shared stringvar somevalue; // The value is now available to the main report. At this point you can do whatever comparison you need with the main report values.

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

(OP)
Kray,

The status field has the following info, 1-30 days, 31-60 days, 61-90 etc.

What I need to do is, pass this value to the main report from the subreport so it allows me to compare the subreport and main report Status field.
e.g.
IF SubReportStatus(previous month) = '1-30 days' AND MainReportStatus(Current month) = '31-60 days' THEN "Worse" ELSE IF
IF SubReportStatus(previous month) = '61-90 days' AND MainReportStatus(Current month) = '91+ days' THEN "Worse"

etc etc

The outcome needs to be on the main report as a field.

Thanks

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

Did you even try what Kray said to do?

Replace "SubReportStatus(previous month)" with the shared variable from the subreport.

Macola Software Veteran and SAP Business One Consultant on Training Wheels

Check out our Macola tools:

www.gainfocus.biz/exceladdin.html

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

(OP)
Yes, I tried what Kray said to do, also took into consideration your point of replacing "SubReportStatus(previous month)" with the shared variable from the subreport" but no luck.

RE: Compare a field from main report against a field from a subreport on CRYSTAL REPORT

Of course a couple of things to remember about shared variables and sub-reports. First of the sub-report or the section it is in cannot be suppressed (there are tricks that you can use to get around this issue if you do not want to see the values in the sub-report). The sub-report has to be in section prior to where you want to see the value in the main report.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close