Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal (9.2) Shared Variables 1

Status
Not open for further replies.

Tech2377

Programmer
Nov 13, 2007
81
0
0
I am using the following Shared Variables, but getting 0's in the calculation field in the Main Report

Main Report - Header
Name: Decl_Vars WhilePrintingRecords;
Shared NumberVar NumErrors1:=0;

SubReport
Name: CalNumErrors1
WhilePrintingRecords;
Shared NumberVar NumErrors1;
NumErrors1 := {#RTot_NumErrors1}

Main Report Group Footer
Name: CalNumErrorPercent
WhilePrintingRecords;
Shared NumberVar NumErrors1;
NumErrors1 / {#Rtot_NonError1}

This is grouped by date (day) so in the Group Header (Main report)
Reset: Main Report Group Header
Name: Reset_NumErrors1
WhilePrintingRecords;
Shared NumberVar NumErrors1 :=0

In the main report where I put the CalNumErrorPercent I get 0s

In the subreport (Group Footer) I checked the variable it does give me the correct number count.
 
Are you saying the subreport is located in the group footer of the main report? Then you need to insert a group footer_b section, and place {@CalNumErrorPercent} in group footer_b, while the sub is in GF_a. A referenced shared variable will only display the correct value if placed in a section below the one in which the sub is located.

-LB
 
I placed the subreport in the report header and the calulation variable to Group Footer 1,

I do get a result but it is the same number.

I need it to look like this

Date Entered NonErrors % of Errors(using the variable Errors1/NonErrors
1/1/07 100 50%
1/1/08 25 5%
1/1/09 125 10%

I also changed the CalNumErrorPercent to:

WhilePrintingRecords;
Shared NumberVar NumErrors1;
NumMEVouchers := DistinctCount ({Errors1},{Entered}, "daily")
 
I have placed as follows:

subreport - Report Header B (when I place it in Group Footer1 it repeats)

Main Report: Group FooterA

both Main Report and subreport are grouped by date(daily)

This is how it looks in main report
Date nonErrors % of Errors (based on shared variable: CalErrors1)
1/2/07 100 25%
1/3/07 50 10%
1/4/07 20 5%

For the calculating Variable name: CalErrors1 in the subreport I used:

WhilePrintingRecords;
Shared NumberVar NumErrors1;
NumErrors1 := {#RTot_Errors1}

I know the variable is correct because I checked it in the subreport and it is picking up correct numbers by date:
ie. Subreport:
Date #of Error1
1/2/07 40
1/3/07 15
1/4/07 35

When I place the Name: CalErrors1Per in the main report - Group Footer 1a

The variable is repeating the same number
1/2/07 35
1/3/07 35
1.4.96 35
For the CalErrors1 (main report) I used:
WhilePrintingRecords;
Shared NumberVar NumErrors1;

When I try a reset variable:

ResetErrors1
WhilePrintingRecords;
Shared NumberVar Errors1 :=0

I get 0's for all the shared variable.

I'm sure it has to do with placement but unsure where the best place to place subreport and also how do I get the count of CalErrors1Percent per day in the shared variable in the main report
 
Assuming that you are expecting the subreport to provide a different value per group, the subreport needs to be placed in a group section of the main report, and should be linked to the main report on the group field. It should be placed either in a GH_b section (after the section containing the reset) or in a GF_a section (before the section containing the calculation).

Your change to the shared variable doesn't make sense, as it references a variable NumMEVouchers that we haven't seen before.

It might help if you explained what it is you are trying to do.

-LB
 
I want to compare non errors with errors1 each day. So I grouped the main report by date and also grouped the subreport by date I am using two different queries
main report contains the number of non errors
Subreport contains number of errors.

I need to use the following calculation to get the % of errors:

Errors / NonErrors
So my main report looks first looked like this
Date # of NonErrors
1/2/07 128
1/3/07 50
1/4/07 60

On Subreport - Errors1
Date # of Errors1
1/2/07 37
1/3/07 8
1/4/07 12

I need the resulting main report to look like this

Date #of NonErrors % Error Rate (this field will use subreport count)
1/2/07 128 30% (Formula using #of Errors1 / Non Errors from the main report)
1/3/07 50 16%
1/4/07 60 20%

So I need to pick up the number of Errors1 in the main report to get the % of Errors.

I moved the subreport to Report Footer B and the main Report Group Footer 1 because I am using Running totals based on the day group.

I am picking up one number but it is the last number of Errors1 (i.e. 12) and it repeats like this in the main report
Date NonErrors # of Errors1
1/2/07 128 12
1/3/07 50 12
1/4/07 60 12

(I will use a formula to get the % but I wanted to make sure it was picking up the correct # of Errors1
Thanks for your patience
 
Please put the subreport in GF_a of the main report and link the sub to the main report on the date field. Go to edit->subreport links-> and link the date fields to each other.

-LB
 
I put the subreport in the GF_B of the main report and the numbers per date weren't aligning. What I am going to do is start over from scratch ...

My report includes a subreport that I am using a shared NumberVar to use the subreport values in main report.
MainReport Totals in GF_1A ( because I am using running totals)

Subreport is in GF_b
Grouped by Date (linked subreport to main report with date field)
When I get my result for shared variable I get 0's on first date:
Date NonErrors Errors(from subreport)
1/3/07 60 0
1/4/07 75 15
1/5/07 112 20

Should be:
1/3/07 60 15
1/4/07 75 20
etc

What should I do to get the sharedvariable from the subreport to appear on the correct dates (I have both reports grouped by date, day)
 
The sub should be in GF_a, and the main report numbers should be in GF_b. Then you can either display the sub results using a formula referencing the shared variable in GF_b, or you can format GF_a to "Underlay following sections" and have only the section containing the desired result showing. The percentage calculation must be in GF_b.

-LB
 
Hi Again,

I have a Crystal report that will have 2 subreports. I have gotten the first subreport complete and sharing variable with main report.

I placed the 2nd subreport into the report (this uses a different query) - I placed it in the Main report in GFB. For some reason it is picking up the same total as the 1st subreport. Do I need to place it differently. This subreport is grouped on date(day) same as main report and subreport. I linked the subreport to the main report by date.

Should look like this
Date
1/2/07
GFC (mainreport) NonErrors 20
GFA (1st subreport) Errors1 10
GFB 2nd subrport) Errors2 4
 
PLEASE DISREGARD LAST POST. It is working as needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top