R – Supressing section in Crystal Reports with subreport

crystal-reportssubreportsuppress

I am trying to create a report in crystal reports 11 based on this sql query

SELECT *
    FROM (table) OM, (table) OL, (table) C
    WHERE OM.ORDER = OL.ORDER
    AND OM.COMPANY = C.COMPANY
    AND (EXISTS (SELECT *
            FROM (table) OSD, (table) OSDD
            WHERE OSD.ORDER = OL.ORDER
           
AND OSD.LINE = OL.LINE
            AND OSD.REVISION = OL.REVISION
            AND OSD.DIM = OSDD.DIM
            AND OSDD.SHAPE = OL.SHAPE))

I thought the best way to start was by creating the main report using the first two tables and creating a subreport using the "EXISTS" section of the query and linking back to the main report.

My details section contains both data from the main report and the subreport. I get the correct results back for where the subreport returns a value, but I want to be able to suppress the detail section of the main report if the subreport is null, but I can't find a way to reference the subreport in any of the selection formulas.

I am open to suggestions if there is a better way to mimic this query as well.

Best Answer

There's no reason to use a subreport if you don't want to see any data where the subreport is null. You're overcomplicating the report.

If you still want to do this, the Suppress attribute allows expressions. You would likely have to use a globalvar variable, set the variable based on the subreport but I doubt it would be set prior to the row being displayed.