none
Hide rectangle if subreport is hidden RRS feed

  • Question

  • I have a main report with a Tablix and in it there are two rows. In first row a sub report is displayed while in second row a rectangle is displayed. The rectangle is being used to give page breaks because page breaks inside sub report doesn't work.

    I want to hide rectangle if sub report is also hidden. To hide sub report I am using following expression.

    IIf(RowNumber(Nothing), True, False)

    It works fine. But how can I also hide the rectangle below? Is there a way I can declare variable in expression and then use it in rectangle expression. For e.g. something like

    IIf(RowNumber(Nothing), True, False)

    If(RowNumber(Nothing))

    hideRectangle = True;

    Else

    hideRectangle = True;

    End If

    And then using the variable hideRectangle in expression of rectangle like below.

    IIf(hideRectangle = True, True, False)
    Sunday, September 7, 2014 11:34 AM

All replies

  • Can you not just handle the page breaks within the tablix grouping?
    Sunday, September 7, 2014 11:05 PM
  • Can you not just handle the page breaks within the tablix grouping?
    No, page breaks within tablix doesn't work in case of sub reports.
    Monday, September 8, 2014 6:15 AM
  • Why don't you use the same expression as what you've got to hide the subreport?

    SQL Server MVP, MCITP/MCTS SQL Server 2008
    Check out my articles at BI: Beer Intelligence

    • Proposed as answer by Avanish Tomar Tuesday, September 9, 2014 2:12 PM
    • Unproposed as answer by Avanish Tomar Tuesday, September 9, 2014 2:12 PM
    Monday, September 8, 2014 6:44 AM
  • Can you try setting an expression for the visibility property of the rectangle


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    Monday, September 8, 2014 7:08 AM
  • Can you try setting an expression for the visibility property of the rectangle


    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

    Ok I will explain why this won't work in my case. Maybe I am doing something wrong and there is a better way to do it.

    In my main report I have a Tablix which is getting data from a dataset. Let's call it DIVISION_DATA and the query is something like:

    SELECT Division_ID, Division_Name FROM DIVISION

    Inside this Tablix are several rows each containing a sub report with rectangle in between. So it is something like:

    Subreport1 ROW1
    Rectangle1 ROW2
    Subreport2 ROW3
    Rectangle2 ROW4
    Subreport3 ROW5
    Rectangle3 ROW6

    Rectangles are bring used to give page break after each sub report.

    Division_ID is passed as parameter to each of these subreports and they use a different Tablix inside with different data set. So once you are inside a sub report the query becomes something like:

    SELECT Department_ID, Department_Name FROM DEPARTMENT WHERE Division_ID = @Division_ID

    So all the datasets inside each sub report have this kind of query (all queries are different depending on subreport) where they are getting @Division_ID from main tablix data set. Sometimes the above query brings data and sometimes not. So if it is not bringing any data, I don't want to show subreport and also the rectangle which is under it.

    If I apply your logic on the main table row (which has subreports) and then rectangle under it then it won't work because the query being run is the first one which will always bring data. It's the query inside subreport which doesn't bring data sometimes.

    If I somehow apply this logic inside subreport then I can't hide rectangle which is outside subreport and is actually inside main report. If I bring rectangle inside subreports then page breaks don't work.


    Wednesday, September 10, 2014 12:12 PM
  • Ok I made another test subreport in which I added all these subreports. So basically one subreport contains all other subreports and page breaks are working fine BUT it gives page break after last page has been displayed.

    Is there a way to avoid it? I mean once last Tablix has been displayed it shouldn't not do page break. But if it is not last then continue to do page breaks.

    Thursday, September 11, 2014 9:31 AM