I have a formula @InitVars in the page header which includes the following, and similar lines:
我在页眉中有一个公式@InitVars,其中包含以下内容和类似的行:
shared numbervar runWaste:=0;
In Details v, I have a sub-report, which has a formula @SetRunWaste:
在详细信息v中,我有一个子报告,其中包含一个公式@SetRunWaste:
shared numbervar runWaste;
if (OnFirstRecord) then
(
if not(isnull({x.x-or})) and
not(isnull({x.y-override})) and {x.y-override} = true then
runWaste:={x.x-or}
else
runWaste:= {x.x}
);
runWaste
I can see the output of this formula in the sub-report is 18.00.
我可以看到子报告中该公式的输出是18.00。
However, both in another sub-report, in Details az, and in the main report in Details w (as a test), I have the following formula @test:
但是,在另一个子报告,详细信息az和详细信息w(作为测试)的主报告中,我都有以下公式@test:
shared numbervar runWaste;
runWaste;
In both places, it shows as 0.00.
在这两个地方,它显示为0.00。
Why is it showing 0 not 18?
为什么它显示0而不是18?
I'm using Crystal Reports version 11.0.0.895.
我正在使用Crystal Reports版本11.0.0.895。
3 个解决方案
#1
The problem is that @InitVars is in the page header, not the report header. It is resetting the variable to 0 at the top of every page.
问题是@InitVars位于页眉中,而不是报表头。它将每个页面顶部的变量重置为0。
Moving @InitVars to the report header fixed it so the correct number comes up in the sub-report in Details az.
将@InitVars移动到报告标题会修复它,以便在详细信息az中的子报告中显示正确的数字。
I still see some odd behavior when I include the variable in the main report, but since that was just for debugging, not the main target, I don't care.
当我在主报表中包含变量时,我仍然会看到一些奇怪的行为,但由于这只是用于调试,而不是主要目标,我不在乎。
#2
I have a vague memory that I'm now having a hard time substantiating about shared variables not passing back up from a subreport. Still looking; good thing it's Friday afternoon.
我有一个模糊的记忆,我现在很难证实共享变量没有从子报表返回。还在寻找;这是周五下午的好事。
Edit: I can't find what I was looking for, so a general thought. Check evaluation time, and make sure that the later section on the main report is evaluating after the subreport (WhilePrintingRecords might be your friend here).
编辑:我找不到我要找的东西,所以一般的想法。检查评估时间,并确保主报表上的后一部分在子报表之后进行评估(WhilePrintingRecords可能是您的朋友)。
#3
From the article Adding Sub reports ,Find Sub Total and Grand Total(To main Report):
从文章添加子报告,查找子总计和总计(到主报告):
Crystal Reports is a business intelligence application used to design and generate reports from a wide range of data sources. Sub Reports are child reports of the main report which can be embedded in main report. Sub reports are very much useful in building reports.
Crystal Reports是一种商业智能应用程序,用于设计和生成来自各种数据源的报告。子报告是主报告的子报告,可以嵌入主报告中。子报告在构建报告时非常有用。
Adding Sub reports find the sub total and grand total of each sub report in the main report
添加子报告可查找主报告中每个子报告的子总计和总计
Main report
Sub Report 1
分报告1
Sub Total: sum (LabTotal )
小计:总和(LabTotal)
Sub Report 2
分报告2
Sub Total: sum (ItemTotal)
小计:总和(ItemTotal)
Grand Total
Sub reports are very useful option in crystal report. Suppose we want to find
子报告在水晶报告中是非常有用的选项。假设我们想要找到
Adding Crystal report
添加Crystal报表
- Add New Item->Crystal Report
添加新项目 - >水晶报告
- If we want to create Crystal Report our own format select “As a Blank Report” from crystal report gallery
如果我们想要创建Crystal Report我们自己的格式,请从水晶报表库中选择“作为空白报表”
- Right Click on the “Database fields” in the Database fields and select tables from the database then make Links (if necessary)
右键单击“数据库”字段中的“数据库字段”,然后从数据库中选择表,然后生成链接(如有必要)
- Right Click from “Details Section” and Add sub report.
右键单击“详细信息部分”并添加子报告。
- Repeat the same things that we have done in the main report and drag needed fields to details section sub report
重复我们在主报表中完成的相同操作,并将所需字段拖到详细信息部分子报表中
For Eg: We are creating labour report the total labour rate can be calculated as
对于Eg:我们正在创建劳动报告,总人工费率可以计算为
In Formula field –name LabTotal
在公式字段中 - 名称LabTotal
WhilePrintingRecords; Shared NumberVar LabTotal := Sum ({PC_LABOUR_DETAILS.Total})
WhilePrintingRecords;共享NumberVar LabTotal:= Sum({PC_LABOUR_DETAILS.Total})
({PC_LABOUR_DETAILS) -- table Total ---field
({PC_LABOUR_DETAILS) - 表格总数---字段
and add sum of LabTotal in to the sub total field
并将LabTotal的总和添加到子总计字段中
If we have another sub report to add ion the main page ,again right click on the “Details Section” and add new section ->Details(b) And repeat step 4 and 5 Here we are adding second sub report for material and subtotal of materials can be caculated as
如果我们有另一个子报告添加主页面,再次右键单击“详细信息部分”并添加新部分 - >详细信息(b)并重复步骤4和5这里我们添加第二个子报告的材料和小计材料可以计算为
In Formula field –name ItemTotal
在公式字段中 - 名称ItemTotal
WhilePrintingRecords; Shared NumberVar ItemTotal := Sum {PC_MATERIAL_DETAILS.Total})
WhilePrintingRecords;共享NumberVar ItemTotal:= Sum {PC_MATERIAL_DETAILS.Total})
({PC_MATERIAL_DETAILS) --table Total -- field
({PC_MATERIAL_DETAILS) - 表总计 - 字段
and add sum of ItemTotal in to the sub total field
并将ItemTotal的总和添加到子总计字段中
Main report
To find the grand total of both sub reports
查找两个子报告的总计
In Formula field name-GrandTotal
在公式字段名称-GrandTotal中
WhilePrintingRecords; Shared NumberVar ItemTotal; Shared NumberVar LabTotal; NumberVar TotalAmount; TotalAmount := ItemTotal+LabTotal; TotalAmount
WhilePrintingRecords;共享NumberVar ItemTotal;共享NumberVar LabTotal; NumberVar TotalAmount; TotalAmount:= ItemTotal + LabTotal;总金额
#1
The problem is that @InitVars is in the page header, not the report header. It is resetting the variable to 0 at the top of every page.
问题是@InitVars位于页眉中,而不是报表头。它将每个页面顶部的变量重置为0。
Moving @InitVars to the report header fixed it so the correct number comes up in the sub-report in Details az.
将@InitVars移动到报告标题会修复它,以便在详细信息az中的子报告中显示正确的数字。
I still see some odd behavior when I include the variable in the main report, but since that was just for debugging, not the main target, I don't care.
当我在主报表中包含变量时,我仍然会看到一些奇怪的行为,但由于这只是用于调试,而不是主要目标,我不在乎。
#2
I have a vague memory that I'm now having a hard time substantiating about shared variables not passing back up from a subreport. Still looking; good thing it's Friday afternoon.
我有一个模糊的记忆,我现在很难证实共享变量没有从子报表返回。还在寻找;这是周五下午的好事。
Edit: I can't find what I was looking for, so a general thought. Check evaluation time, and make sure that the later section on the main report is evaluating after the subreport (WhilePrintingRecords might be your friend here).
编辑:我找不到我要找的东西,所以一般的想法。检查评估时间,并确保主报表上的后一部分在子报表之后进行评估(WhilePrintingRecords可能是您的朋友)。
#3
From the article Adding Sub reports ,Find Sub Total and Grand Total(To main Report):
从文章添加子报告,查找子总计和总计(到主报告):
Crystal Reports is a business intelligence application used to design and generate reports from a wide range of data sources. Sub Reports are child reports of the main report which can be embedded in main report. Sub reports are very much useful in building reports.
Crystal Reports是一种商业智能应用程序,用于设计和生成来自各种数据源的报告。子报告是主报告的子报告,可以嵌入主报告中。子报告在构建报告时非常有用。
Adding Sub reports find the sub total and grand total of each sub report in the main report
添加子报告可查找主报告中每个子报告的子总计和总计
Main report
Sub Report 1
分报告1
Sub Total: sum (LabTotal )
小计:总和(LabTotal)
Sub Report 2
分报告2
Sub Total: sum (ItemTotal)
小计:总和(ItemTotal)
Grand Total
Sub reports are very useful option in crystal report. Suppose we want to find
子报告在水晶报告中是非常有用的选项。假设我们想要找到
Adding Crystal report
添加Crystal报表
- Add New Item->Crystal Report
添加新项目 - >水晶报告
- If we want to create Crystal Report our own format select “As a Blank Report” from crystal report gallery
如果我们想要创建Crystal Report我们自己的格式,请从水晶报表库中选择“作为空白报表”
- Right Click on the “Database fields” in the Database fields and select tables from the database then make Links (if necessary)
右键单击“数据库”字段中的“数据库字段”,然后从数据库中选择表,然后生成链接(如有必要)
- Right Click from “Details Section” and Add sub report.
右键单击“详细信息部分”并添加子报告。
- Repeat the same things that we have done in the main report and drag needed fields to details section sub report
重复我们在主报表中完成的相同操作,并将所需字段拖到详细信息部分子报表中
For Eg: We are creating labour report the total labour rate can be calculated as
对于Eg:我们正在创建劳动报告,总人工费率可以计算为
In Formula field –name LabTotal
在公式字段中 - 名称LabTotal
WhilePrintingRecords; Shared NumberVar LabTotal := Sum ({PC_LABOUR_DETAILS.Total})
WhilePrintingRecords;共享NumberVar LabTotal:= Sum({PC_LABOUR_DETAILS.Total})
({PC_LABOUR_DETAILS) -- table Total ---field
({PC_LABOUR_DETAILS) - 表格总数---字段
and add sum of LabTotal in to the sub total field
并将LabTotal的总和添加到子总计字段中
If we have another sub report to add ion the main page ,again right click on the “Details Section” and add new section ->Details(b) And repeat step 4 and 5 Here we are adding second sub report for material and subtotal of materials can be caculated as
如果我们有另一个子报告添加主页面,再次右键单击“详细信息部分”并添加新部分 - >详细信息(b)并重复步骤4和5这里我们添加第二个子报告的材料和小计材料可以计算为
In Formula field –name ItemTotal
在公式字段中 - 名称ItemTotal
WhilePrintingRecords; Shared NumberVar ItemTotal := Sum {PC_MATERIAL_DETAILS.Total})
WhilePrintingRecords;共享NumberVar ItemTotal:= Sum {PC_MATERIAL_DETAILS.Total})
({PC_MATERIAL_DETAILS) --table Total -- field
({PC_MATERIAL_DETAILS) - 表总计 - 字段
and add sum of ItemTotal in to the sub total field
并将ItemTotal的总和添加到子总计字段中
Main report
To find the grand total of both sub reports
查找两个子报告的总计
In Formula field name-GrandTotal
在公式字段名称-GrandTotal中
WhilePrintingRecords; Shared NumberVar ItemTotal; Shared NumberVar LabTotal; NumberVar TotalAmount; TotalAmount := ItemTotal+LabTotal; TotalAmount
WhilePrintingRecords;共享NumberVar ItemTotal;共享NumberVar LabTotal; NumberVar TotalAmount; TotalAmount:= ItemTotal + LabTotal;总金额