Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7808453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:08:22+00:00 2026-06-02T03:08:22+00:00

Background I’m attempting to do some nice looking validation on the details row of

  • 0

Background

  • I’m attempting to do some nice looking validation on the details row of my report.
  • I have several formulas named as Assert statements, that return false if they fail a test and true if they pass.

Goal

  • I would like to create an array that stores “rule violations” and then displays them in a field at the end of the row, under a heading called “Broken Rules”

What I’ve done so far

  • Created an Array and Initialized it as an empty string array in the report header
  • Created a formula to do evaluation of each rule, increment the array, and add the broken rule number (this is repeated code for each rule, nothing fancy). This gets added into a suppressed details section above my details display.
  • Created a formula that is a join of the elements in the rules broken array. This is a formula that is displayed along with my detail fields.
  • Created a formula to set the rules broken array to empty. This goes in a suppressed details section after my details display.

Problem

  • Crystal doesn’t seem to allow an “end if” statement that I can find.
  • As such, it appears I can only evaluate one If statement and not multiples within a single formula.
  • This means I can’t do multiple ifs, one for each rule.

Sample Code

Creation of the Array (a formula called Init_StringVar_Array_RulesBroken):

//@Init
//This goes into the report header
WhilePrintingRecords;

//initializes the array of broken rules which we'll add to during details
StringVar Array RulesBroken;
"";

Sample of first three rule assessments that increment arrays and add values (this is in a formula called Increment_StringVar_Array_RulesBroken):

//@Increment
//Goes before the details section is displayed

//accesses the shared variable
WhilePrintingRecords;
StringVar Array RulesBroken;

//separate if statement for each assert statement

//01
if not {@Assert_01_IfCrewIsConstructionCrew_CBFlagShouldBeYesOrDirect} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "01"; //adds the new string into the array

//02
if not {@Assert_02_IfCrewIsConstructionCrew_AndCBFlagIsDirect_WONumberShouldStartWithC} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "02"; //adds the new string into the array

//03
if not {@Assert_03_IfCrewIsDesign_AndCBFlagIsDirect_WONumberShouldStartWithD} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "03"; //adds the new string into the array

Any Ideas?

  • Is there an If / then / end if capability in Crystal Reports?
  • If not, is there a workaround for this sort of thing in Crystal Reports? do I need to create multiple formulas for each one and make sure they’re placed after the other or something like that?

Thanks in advance for any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:08:24+00:00Added an answer on June 2, 2026 at 3:08 am

    The simplest way to do this with the code you have is wrapping the if blocks in parentheses and separating them with semicolons:

    //01
    (
        if not {@Assert_01_IfCrewIsConstructionCrew_CBFlagShouldBeYesOrDirect} then
            Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
            RulesBroken[UBound(RulesBroken)] := "01"
        else ""
    );
    
    //02
    (
        if not {@Assert_02_IfCrewIsConstructionCrew_AndCBFlagIsDirect_WONumberShouldStartWithC} then
            Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
            RulesBroken[UBound(RulesBroken)] := "02"
        else ""
    );
    
    //03
    (
        if not {@Assert_03_IfCrewIsDesign_AndCBFlagIsDirect_WONumberShouldStartWithD} then
            Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
            RulesBroken[UBound(RulesBroken)] := "03"
        else ""
    );
    

    I added indentation indicating how Crystal interprets the blocks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I have several builds running on a Windows Server 2003 R2 machine via
Background: I have some existing apps in the App Store and I have just
Background I have a secured folder containing secret report files (in pdf format). Each
Background I have a pair of functions I want to use to animate some
Background: I have an opc tag whose value is a 32 bit floating point
Background I have an installation of VisualSVN on a server. under this, I have
Background: I have a website where people can store transactions. As part of this
Background: I have a css and a js that is used only by the
Background: Sometimes when editing in vim it is possible to have extra characters in
Background I have a ror application which is continuously recording and showing on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.