Search code examples
crystal-reports

How to print between the Details Section or Subreport in Crystal Reports?


I have created a CR with 2 different letters. One letter is in the Details Section and the other letter is in a Subreport.

Basically, if the table.field = 1,2,3 or 9 then I want to print the Subreport. If the table.field <> 1,2,3 or 9 then I want to print the Details Section.

I know that I would need to suppress one over the other but I don't know the easiest way to do this.

Any suggestions would be greatly appreciated. Thanks!


Solution

  • The easiest way to do it is next.

    Your report contains :

    1. subreport which shows if value of field is 1,2,3 or 9
    2. detail section shows if value of field is <> 1,2,3 or 9

    Go to section expert, detail section and under "supress" write formula

    enter image description here

    if ({table.field} = 1 or {table.field} = 2 or {table.field} = 3 or {table.field} = 9) = false then false
    else true
    

    Right click on subreport and unders "supress" triger write formula. enter image description here

    Formula for subreport is

    if {table.field} = 1 or {table.field} = 2 or {table.field} = 3 or {table.field} = 9 then false
    else true
    

    And this should do the trick. I'm sure there is other ways to solve this situation, but this is how i do it.

    Hope it helps you :)