Dynamically Moving Report Objects if SubReport Suppressed


I hope i am asking a question which has a very simple answer, but for all my trying i dont seem able to find it.

I want to put a subreport into the Report Footer alongside an existing chart object (so that the subreport is to the left of the chart). Ideally i would really like to have the subreport in the same section as the chart.

This works well if the subreport contains data - the report looks neatly formatted.

However if the subreport does not contain any data i would like to suppress it and then move the chart object across to cover the entire space of the report footer (else the report has a silly blank space in it).

Does anybody have any ideas on how to achieve this ? - all i want to do is say 'if the subreport is suppressed then resize the chart to cover the bigger space'

Many thanks in advance for your help.

Who is Participating?
frodomanConnect With a Mentor Commented:
What I would do is to create two charts - a full size one and a half size one and put them in different report footer sections.  If the subreport is suppressed then suppress the entire report footer a and don't suppress report footer b (containing the full size report).  If the subreport isn't suppressed then do the opposite.
wilkinsgAuthor Commented:
Sounds like it should work nicely.

One question thou' - How do i suppress the entire report footer/not the other one if the subreport is to be suppressed ?


That is probably the best way to do it.  Trying to resize an object would be difficult at best.

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Which version of Crystal? In version 9, you can say on subreport itself to suppress if blank, in previous versions that was impossible.
 And you can put subreport in separate section, and suppress section if blank also.
 SubReport can return shared variable that will notify main report that it should unsuppress other one...

Lady Linet
wilkinsgAuthor Commented:
It is version 9.

Sounds like creating 2 separate sections and then suppressing one or the other based upon the supreport sounds like the way to go.

But i am not sure how to suppress the subsections based on the subreport suppression value.

Lady Linet you mentioned that it is possible to use a shared variable to notify the main report - could you please expand upon this ?

Many Thanks
ladylinetConnect With a Mentor Commented:
In subreport, create formula field and put something like this in it:

 Shared blnNoData As Boolean

 IF Not(Isnull(Count({Report1.ID}))) or Count({Report1.ID}) > 0 Then
  blnNoData = True
 blnNoData = False
End IF

 where Report1.ID is field that you are expecting to exist

In main report create another formula on suppress, and put something like this:
 Shared blnNoData As Boolean
 If blnNoData = True Then
  formula = True '-- hide
  formula = False ' -- show
End IF

Lady Linet
Lady Linet's implementation is similar to what I was thinking on the first post.  Maybe a couple things you can simplify if you want though.

In the subreport you can simply use this formula in the report footer:
       OnFirstRecord and OnLastRecord and RecordNumber<>1

There's nothing wrong with LL's approach - this one is more portable and can be used on any subreport regardless of the data fields.

For the suppression formula you can simply use: bInNoData

Since this value is already true or false there's no need to run it through an if/then statement.
Hi frodoman, are you sure that RecordNumber is working? When I've tried it, I've got 1 even for empty (main) report ...
 And for If/Then, it's just more readable for me that way.

Lady Linet
wilkinsgAuthor Commented:
Many thanks for all your help - i now think i can produce the report exactly as i need it.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.