Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Suppressing main report when subreport blank Post Reply Post New Topic
Author Message
bearz
Newbie
Newbie
Avatar

Joined: 20 Oct 2009
Location: Australia
Online Status: Offline
Posts: 1
Quote bearz Replybullet Topic: Suppressing main report when subreport blank
     Posted: 20 Oct 2009 at 5:09pm
Hi
 
I was wondering how I should go about suppressing a record in the detail section of the main report when the associated subreport record is blank. Using Crystal Reports XI.
 
Basically the main report contains a full listing of all projects associated with a particular business unit. The subreport is looking at all notes/comments made against these projects and only returning those comments entered after a particular date (with the date being a parameter entered by the report user).
 
The report is currently returning all projects where there are no comments + those that meet the date criteria. I need to suppress the records that have no comments entered.
 
I'm assuming that I need to return a record count to the main report and then place a suppress criteria in the relevant Section Expert of the main report, but I haven't done this before and need a few pointers.
 
Cheers Bearz
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 21 Oct 2009 at 6:29am
create a formula in the subreport that sets a shared variable to the count, since it is just a reference count, something like this should do, in the subreport footer:
shared numbervar aCount:=count({table.field});
 
in the main report, in the suppression criteria for the section with the subreport something like:
shared numbervar aCount;
aCount =0
 
A concern is a blank subreport, which might not update the variable, and hence use the last value, which would display incorrectly.
 
If you are getting the data from a stored proc, you could filter out the records that have no valid values in the subreport before you even get here.  You might be able to filter in the Record Selection for the report...I use stored procs, so am more familiar with them.
 
HTH


Edited by lockwelle - 21 Oct 2009 at 6:33am
IP IP Logged
mdp10
Newbie
Newbie
Avatar

Joined: 03 Dec 2009
Location: United States
Online Status: Offline
Posts: 2
Quote mdp10 Replybullet Posted: 03 Dec 2009 at 6:43am
I have a report that is using a subreport that calls a stored procedure for every record. The main report passes parameters into the SP and if things match up the SP returns data. I need to suppress the records in the main if the SP does not return any data. I tried what you suggested using the shared variable and it does not work. As you pointed out  "A concern is a blank subreport, which might not update the variable, and hence use the last value, which would display incorrectly". I tried to create a group and put all the info in the group but you can't put the stored procedure in the group.
You mentioned that there might be a way to suppress the records in the main report selection criteria. Could you expand on that idea?  I do not see any access to the subreport when trying to edit the selection criteria.
 
Thnak you,
 
Matt
Matt
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Dec 2009 at 10:29am

1) how are you getting the data for the main report?

  if you are using a stored proc, you might consider adding the info for the subreport, or adding a flag if there will be records from the subreport.
IP IP Logged
mdp10
Newbie
Newbie
Avatar

Joined: 03 Dec 2009
Location: United States
Online Status: Offline
Posts: 2
Quote mdp10 Replybullet Posted: 03 Dec 2009 at 11:30am
I am using a DSN to an Oracle database and just linking various tables to get the main report information. The subreport connects to another data source (Tandom NonStop SQL) and all it does is call a SP that i do not have permission to modify.
Matt
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 03 Dec 2009 at 1:28pm
hmmm...if you can't see a way to determine if the subreport return a record, there isn't much that you can do.
 
There is one suggestion, I am loath to make it, as it doubles the subreport performance penalty, but you could run the subreport prior to group header and use the result to suppress the group, bassackward, but it should work...it will just slow down the report.
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