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.



  • 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"
            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
            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:

    <FONT color=#0000ff size=2>

    Sub</FONT><FONT size=2> OnFetchData(eof)

    </FONT><FONT color=#0000ff size=2>If</FONT><FONT size=2> Rpt.Fields("SummaryBoolean").Value </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

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

    </FONT><FONT color=#0000ff size=2>Else

    </FONT><FONT size=2>

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

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>If

    End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT>

    <FONT color=#0000ff size=2><FONT color=#000000>And:</FONT></FONT>

    <FONT color=#0000ff size=2><FONT color=#0000ff size=2>

    Sub</FONT><FONT size=2><FONT color=#000000> OnFormat</FONT>

    </FONT><FONT color=#000000 size=2>If</FONT><FONT size=2><FONT color=#000000> Rpt.Sections("Detail").Controls("txtSummaryYN").Text = "Y"</FONT> </FONT><FONT color=#0000ff size=2>Then

    </FONT><FONT size=2>

    <FONT color=#000000>Rpt.Sections("Detail").Visible =</FONT> </FONT><FONT color=#0000ff size=2>False

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>Else

    </FONT><FONT size=2>

    <FONT color=#000000>Rpt.Sections("Detail").Visible =</FONT> </FONT><FONT color=#0000ff size=2>True

    </FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2>End</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>if

    End</FONT><FONT color=#000000 size=2> </FONT><FONT color=#0000ff size=2>Sub</FONT>

    <FONT color=#0000ff size=2><FONT color=#000000>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.</FONT></FONT>

    <FONT color=#0000ff size=2><FONT color=#000000>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.</FONT></FONT>

    <FONT color=#0000ff size=2><FONT color=#000000>Thanks for your initial response.  It made it a good bit clearer and moving forward.</FONT>

  • 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.


Need extra support?

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

Learn More

Forum Channels