Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: looking up data in a subreport Post Reply Post New Topic
Author Message
muncy
Newbie
Newbie


Joined: 12 Oct 2011
Online Status: Offline
Posts: 6
Quote muncy Replybullet Topic: looking up data in a subreport
     Posted: 28 Sep 2012 at 12:35am
Hi
 
I have a report that shows tickets that have been assigned to a department. This has a subreport that shows tickets that had breached their SLA when they were assigned. The nature of the database means that breached tickets have to be in a subreport.
 
What I'd like to do is hide the subreport and apply a format to the ticket number field in the main report if that ticket number appears in the subreport, i.e. something like:
 
if ticket number 12345 (mainreport) exists in ticket field (subreport) then crred.
 
Any suggestions on how I can do this?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 28 Sep 2012 at 8:11am
well, if you just want to notify, you could build add a formula in the subreport that would check if the ticket number from the main report matched in the subreport.
 
using shared variables, this isn't too bad...
 
in the subreport you would have something like:
shared booleanvar ticketHere;
if {table.field} = {?parameter} then
  ticketHere := true;
""  //will hide the output.
 
in the main report your formula would start:
shared booleanvar ticketHere;
 //insert your logic for the message.
 
now the caveats:
1) you need to run the subreport in a section before the main report's formula for the message is run.
 
2) if you don't want to display the subreport, you need to have it display no fields, just a blank report...the formulas will run and the data will be read, but nothing will be displayed. Then back inthe main report, SectionExpert you need to select Suppress if Blank.  This way the subreport will run, but nothing will be displayed in the main report.
 
HTH...or least points the way
 
IP IP Logged
muncy
Newbie
Newbie


Joined: 12 Oct 2011
Online Status: Offline
Posts: 6
Quote muncy Replybullet Posted: 30 Sep 2012 at 11:58pm
Hi Lockwelle
 
Thank you so much for your reply.
 
I have the subreport in the report header section of the main report but I'm not sure that this is right to get it to run before the main report. My formula in the subreport is:
 
shared booleanvar ticketHere;
if {INCIDENT.INCIDENT_REF} = {?Pm-INCIDENT.INCIDENT_REF} then
  ticketHere := true;
 
and I am linking the subreport on INCIDENT.INCIDENT_REF
 
The formula in the main report is (for now) simply:
 
shared booleanvar ticketHere;
 
It says "False" against all the values but there is one match which should be true.
 
Is it just that my subreport isn't running at the right time?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Oct 2012 at 4:36am

if you put it in the report header, it will only run once per report, which probably not what you are after.

if your report has groups, you might want to run the subreport in the group header, if it doesn't, you might want to run the subreport in the details as well.

 

HTH

IP IP Logged
muncy
Newbie
Newbie


Joined: 12 Oct 2011
Online Status: Offline
Posts: 6
Quote muncy Replybullet Posted: 01 Oct 2012 at 5:14am
Got it! Many thanks.
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