Script to make detail section not visible in RPX file

Posted by: jww on 4 August 2017, 2:59 pm EST

  • Posted 4 August 2017, 2:59 pm EST

    I have a record set with a field that is always a 1 or 0 and I want to use that field to dynamically hide the detail section of the report.


    I've tried a number of combinations in the onFormat to set the visible to false along with some attempts with report level datainitialize etc.


    It appears to not use the actual value in the record set and always assumes zero.


    Can you please explain or provide examples of the event(s) I need to place script in to hide the detail section lines?


    Thanks for your help to an obvious novice.


    JWW


     

  • Replied 4 August 2017, 2:59 pm EST

    Place an unbound textbox in the detail section. In FetchData set the text property of this textbox according to the value of the boolean field you have.

    Sub OnFetchData(eof)
        If Rpt.Fields("NewCustomer").Value Then
            Rpt.Sections("Detail").Controls("txtNewCustomer").Text = "Y"
        Else
            Rpt.Sections("Detail").Controls("txtNewCustomer").Text = "N"
        End If
    End Sub

    If you don't need this textbox, you can hide it. In the format event of the detail section check the value of this textbox and set the visibility of the section accordingly:

    Sub OnFormat
        If Rpt.Sections("Detail").Controls("txtNewCustomer").Text = "Y" Then
            Rpt.Sections("Detail").Visible = True
        Else
            Rpt.Sections("Detail").Visible = False
        End if
    End Sub

  • Replied 4 August 2017, 2:59 pm EST

    I put in the script the way you described, but it does not seem to pass the information between the two.


    If I comment all but one or the other of the choices in Fetchdata, it works after the compile in the designer, but not in the actual application after saving the RPX etc.


    I have entered:


    Sub OnFetchData(eof)


    If Rpt.Fields("SummaryBoolean").Value Then


    Rpt.Sections("Detail").Controls("txtSummaryYN").Text = "Y"


    Else


    Rpt.Sections("Detail").Controls("txtSummaryYN").Text = "N"


    End If


    End Sub


    And:


    Sub OnFormat


    If Rpt.Sections("Detail").Controls("txtSummaryYN").Text = "Y" Then


    Rpt.Sections("Detail").Visible = False


    Else


    Rpt.Sections("Detail").Visible = True


    End if


    End Sub


    Note the reversal of the True and False from the example you sent - it is the result of tweaking the compile/designer output and not necessarily the end result.


    I am at a loss, again, it functions as if the OnFormat of the Detail Section was not in anyway influenced by anything I do in the OnFetchData.


    Thanks for your initial response.  It made it a good bit clearer and moving forward.

  • Replied 4 August 2017, 2:59 pm EST

    Nevermind and thank you very much.


    I have figured out my error - the field I used in the detail section to carry the Y/N had an entry in the DataField property and once I removed it, all worked as planned.


    I appreciate how quickly you got me on the right path.


    Thanks again.


    JWW

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels