You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Crystal Reports条件文本输出优化:消除多页生成问题

Fixing Crystal Reports Formula to Avoid Extra Pages & Show Single Alert

Got it, let's sort out this issue for you. The problem with your current formula is that it checks every single line item in the detail section—so every matching item outputs the text, and even non-matching items leave an empty line that adds extra page space. Instead, we need to check if any item in the order matches your list, then show the alert once without extra pages.

Here are two reliable solutions:


Solution 1: Use a Running Total (Simplest Approach)

Running Totals let you count matching items across the entire order group, then trigger the alert only if there's at least one match.

Step-by-Step Setup:

  1. Create a Running Total:

    • Go to Field Explorer > Running Totals > New
    • Name it HasClassVIItem
    • Under "Field to summarize", select oeordlin_sql.item_no
    • Set "Type of summary" to Count
    • For "Evaluate", choose Use a formula and enter:
      {oeordlin_sql.item_no} IN [
        '022471-2000', '142846-003', '202522-2000',
        '022468-2000', '202522-2010', '202258-01',
        '142845-002', '142847-20204', '142848-01402',
        '142848-01408', '142849-001'
      ]
      
    • For "Reset", choose On change of group and select your order group (e.g., oeordhdr_sql.order_no—you should already have this group set up to group by order)
    • Click OK to save the Running Total.
  2. Add the Alert Text:

    • Place a text box in your Group Footer (or Group Header, if you prefer the alert at the top of the order)
    • Replace the text with this formula:
      If {#HasClassVIItem} > 0 Then "Class VI Certification Required" Else ""
      
  3. Prevent Empty Sections:

    • Right-click the Group Footer section > Section Expert
    • Under "Suppress", click the formula button and enter:
      {#HasClassVIItem} = 0
      
    • This hides the footer entirely when there are no matching items, so no extra blank pages.

Solution 2: Use Global Variables (More Flexible for Complex Logic)

If you need more control, use a global boolean variable to track if any matching item exists in the order.

Step-by-Step Setup:

  1. Initialize the Variable in Group Header:

    • Create a new formula (name it InitClassVI) and place it in your Order Group Header:
      Global BooleanVar hasClassVI := False;
      ""  // Output nothing, just initialize the variable
      
  2. Check Each Item in Detail Section:

    • Create another formula (name it CheckClassVI) and place it in the Detail section:
      Global BooleanVar hasClassVI;
      If {oeordlin_sql.item_no} IN [
        '022471-2000', '142846-003', '202522-2000',
        '022468-2000', '202522-2010', '202258-01',
        '142845-002', '142847-20204', '142848-01402',
        '142848-01408', '142849-001'
      ] Then
        hasClassVI := True;
      ""  // Output nothing, just update the variable
      
  3. Show the Alert in Group Footer:

    • Create a final formula (name it ShowClassVIAlert) and place it in your Order Group Footer:
      Global BooleanVar hasClassVI;
      If hasClassVI Then "Class VI Certification Required" Else ""
      
  4. Hide Empty Footer:

    • Like Solution 1, go to Section Expert for the Group Footer, set "Suppress" to:
      Not Global BooleanVar hasClassVI
      

Both approaches will:

  • Only check if any item in the order matches your list
  • Show the alert once per order (no duplicate text)
  • Avoid extra blank pages by hiding the section when there's no match

内容的提问来源于stack exchange,提问作者Travis

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 07:59:05