Crystal Reports Suppress On Zero - crystal-reports

I have a summary reports that looks at all stock items, available sizes, sales and transactions.
The report consists
Stock Reference
Weight (ton,load, net etc)
Sub report containing transaction data
All the items are in a group header within the main report.
I wanted to be able to hide the header if an item from the sub report was Zero.
I set up a shared variable which passes the quantity from the sub report to the main report, however this is not processed until the group header is displayed.
To compensate i duplicated everything in the group header and placed it in the group footer (including the shared variable form the sub report).
My thinking was that i could suppress the group header permanently and the group footer conditionally if the shared variable is 0 (if {#SharedQuantity} = 0 then true).
Currently if i suppress the group header the whole report is blank. If i dont suppress the header the footer acts correctly, suppressing rows on items that dont have a quantity.
I assumed that suppressing items still meant that they where processed and hence the shared variable would still be set.

The answer to the above was to suppress all the fields within the sub report in the group header, then setting the group header as suppress if blank. This way the shared variable was still populated and the conditional suppress on the group footer worked as expected.

Related

Crystal reports: how to conditionally suppress sections

I am having difficulty suppressing a group header if another group header is blank/suppressed.
Originally I had a layout as follows:
Group Header a - contains client details
Group Header b - contains a subreport that showed details of the incoming calls from client that were received in the last 24 hours.
If the sub report in group header b was blank (because no calls had been received in the last 24 hours), my report was still showing the client details in group header a.
I can suppress the group header b section if the subreport is blank, but cannot work out how to suppress group header a if group header b is blank/suppressed.
After reading various other discussions, I understood that if you want to suppress a section when a subreport is blank, then the subreport would need to be in a section before the section you want to suppress.
So, I changed my layout as follows:
Group Header a - contains sub report showing details of calls in last 24 hours (sub report is suppressed if blank, and group header a is suppressed if blank)
Group Header b - contains client details
Group Header c - contains same subreport showing calls received in last 24 hours
So what I now need to work out is, how do I suppress group header b and c if group header a is suppressed?!
Any help would be greatfully received.
You will need to check record count of sub report, if it is zero then suppress the group using conditional suppress formula. So basically in your group query somewhere you must have field which keeps the count of records in sub report.
Right Click on section
Section Expert
Suppress No Drill
Click x-2 formula editor
if {count} = 0 then true else false
Where {count} is the field having total records for that group
Hope this helps you!

Show text if Section is suppressed

I am trying to display a certain message in the Report Header section based off if the Report Footer section is suppressed.
I need something like... ifSuppressed()
Does something exist like that in Crystal Reports?
In case something similar does not exist... here is my ultimate goal.
I need a value to be determined in the Report Footer section. If said value is greater than another value then I need a message to be displayed in the header.
The problem which I believe is that one of the values used in the calculation in the footer is from a sub report which I had to put in the Page Header to get what I needed. Therefore, I could not pass the value above the Page Header to the Report Header so I am trying to see if I could determine if a section is suppressed (Which is based off some variables in the sub report) and go from there.
Sorry if that is confusing and can elaborate if needed.
Of course after I post a question... I typically figure it out.
So here it is.
I created another formula to grab the SUM I was looking for with the running total.
I also created a formula to grab the amount I need to compare to (Which was from the subreport).
I then created an additional header so I have now header 1 and header 2. I put the subreport in header 1 and the two formulas in header 2. This way I can grab the sum and pass the number from the footer to the header because the subreport is above in header 1.
I then could do my comparison and display my message correctly.

Crystal Report Sub report Shared Variable is not returning to concern Group section

Crystal Report
Sub report Shared Variable is not returning to concern Group section as Shown Below with simple example.
After making Shared variable in both main and sub, values of subrepo need to return in corresponding main report field. but instead it returns on next group section as shown below
Group1
SharedVAR Sales Happen=
Group 2
Sub Report
date sales
1-jan-2012 123.44 SharedVAR Sales happen=Y
Group1
SharedVAR Sales Happen=Y
Group 2
Sub Report
date sales
-- No records
Please suggest Thank you in advance.
SHB
The problem here is that shared variables are always evaluated while printing, and the Group1 header is printed before Group2. If you move the totals to display in the Group1 footer instead of the Group1 header, it should work fine.
Depending on the report, you also may be able to combine them together: either move the sub-report data into the main report (and get rid of the sub-report), or suppress the group1 header in the main report and show that data in the report header section of the sub-report.

Making report footer to appear just below the last page records

I am using Crystal Reports with VS-2005.
I have a report with a report footer section comprising of sum totals of a column. The problem is that in some cases, the records consume the entire page and the report footer alone appears on the next page. It looks awkward. I want the report footer to appear just below the last record row ended.
Is there any trick to make the report footer section fit on the last page itself?
If you aren't using grouping, try this:
Add an additional section below your last detail section.
In Section Expert, mark the detail section Keep Together.
For the suppress formula for the new section, specify Not OnLastRecord.
Move the content from the report footer to the new detail section.
If you are using grouping, do this in the last group footer instead, and in Group Expert, mark the group Keep Group Together.

Crystal Reports: global variable running total not displaying in header

Using Crystal Reports I'm trying to display the running total of a database field in the header where all the labels are.
I've attempted to do this by placing the running total (RTversion) into a formula field with the following:
Shared stringvar CurrentVers;
CurrentVers := {#CurrentVers};
and then in the page header section I have the following:
Shared stringvar CurrentVers;
EvaluateAFter({#currentVers});
CurrentVers;
with {#CurrentVers} running the 1st largest number.
Is this incorrect?
Update: The goal is to display the latest version in the header near the labels to show what the current verseion is for comparison.
Running-Total Fields, in my experience, only work in the footer sections.
You will need to create a manual running total.
Add a formula field to the Details section that populates a Global variable with whatever you are trying to capture. Something like:
//use WhileReadingRecords if the values can be gathered as the report pulls in values from the database. Otherwise, use WhilePrintingRecords.
WhileReadingRecords;
Global Stringvar CurrentVers;
//logic here to capture what you want
CurrentVers:=...
Add another formula field to the Header section. Add these two lines to it:
WhilePrintingRecords;
Global Stringvar CurrentVers;
Create a formula like this
formula = Count ({Field to count},{GroupFieldName})
and place it in group header section.
I figured it out..
I had to add a subreport to the main report. I copied the main report and renamed it as a subreport. In the subreport, I added a shared variable and then passed it to the main report. The trick is to place the subreport in the same group header, but a separate section above the section that needs to be suppressed. I actually added the following sections:
New section (same group-I placed subreport here; do not suppress)
New Section (same group - I placed shared variable value here; do not suppress)
Original Section (same group that has a header I need suppressed based on a running total)
If {#CurrentVers} is a regular running total field, you should be able to place it in the page header directly rather than resort to an additional formula. I don't see the need for either formula field here, unless there's something unusual in the composition of {#CurrentVers} and a 'largest number' running total shouldn't require anything out of the ordinary.
You can solve this with just one formula field:
WhilePrintingRecords;
// Enter logic here e.g.
// maximum({mytable.myfield});
The WhilePrintingRecords; forces the formula to not be evaluated until all records have been read from the database, and therefore the formula field will display the correct result even if placed in a header.
The key I found is that the formula field being passed needs to be placed on the subreport. I placed mine in the footer then suppressed it.