首页 文章

Crystal Reports公式变量传递

提问于
浏览
1

我正在编写此报告,将按月分组的所有预计购买数据显示为一个总和(本月称为 "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 回答

  • 1

    尝试使用一个标志变量,该变量表示是否已报告第一个月 . 我最初使用New_Balance作为0,但这可能会自然而然地发生 .

    所以,像

    报告 Headers 中的初始化程序:

    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
    

相关问题