Crystal Reports公式变量传递

时间:2013-03-11 20:04:02

标签: crystal-reports formula

我正在处理此报告,将按月分组的所有预计购买数据显示一个总和(本月称为"Monthly_Total",并显示该月的预算(称为"Monthly_Budget"。我也是有一个子报表,我使用共享currencyvar "Starting_Balance"。每当报表运行时,此共享变量都会更新。  我需要找到一种方法来进行以下计算:

第一个月(在这种情况下,报告从三月开始)应该是

"Starting_Balance" + "Monthly_Total") - "Monthly_Budget" = "New_Balance"

每个后续月份都将使用公式

("New_Balance" + "Monthly_Total") - "Monthly_Budget"

我可以让它为第一个组页脚工作,但之后每个月都会引用回"Starting_Balance"而不是"New_Balance"

任何想法?

1 个答案:

答案 0 :(得分:1)

尝试使用一个标志变量,说明是否已报告第一个月。我最初使用New_Balance作为0,但这可能会自然发生。

所以,像

报告标题中的初始化程序:

WhilePrintingRecords;
Global BooleanVar First_Month_Done := false; // have we printed the first month?
""; // print nothing on screen

每月公式

WhilePrintingRecords;  // Optional when using shared variables
Global BooleanVar First_Month_Done;
Global CurrencyVar New_Balance;  //or whatever it is
Shared CurrencyVar Starting_Balance;
// Assuming "Monthly_Total" and "Monthly_Budget" are formulas, not variables

If First_Month_Done
    Then New_Balance := New_Balance + {@Monthly_Total} - {@Monthly_Budget}
    Else New_Balance := Starting_Balance + {@Monthly_Total} - {@Monthly_Budget};

First_Month_Done := true;
New_Balance