Unbound Text Boxes in Page Header Value Updated based on Detail

Posted by: sfee on 4 August 2017, 3:07 pm EST

  • Posted 4 August 2017, 3:07 pm EST

    I have an rpx file with fields added in DataInitialize.  These fields are in the page header.  The value of each of these text boxes is set to text values based on the data read in the FetchData event.  The page header is correct on page 2 but is blank on page one.  I am assuming this is because the page header is rendered prior to reading the actual data.  These are NOT calculated fields so using summary operations does not seem to be a solution.  Is there a way to set the values based on the around this issue?

    Thanks in advance.


  • Replied 4 August 2017, 3:07 pm EST

    My version is actually  I cannot update the version due to what is being used by our other packages.  I would appreciate it if you would take a look at the rpx file though and see if there is anything I can do short of upgrading.  If this would definitely be fixed with the latest version, let me know so I can discuss with our other developers.

    Thanks for your help and prompt response to my post.


  • Replied 4 August 2017, 3:07 pm EST

    The upload of the file failed for some reason.  Here is the script code:

    Sub OnReportStart
      for i = 1 to 13
        rpt.fields("Bucket" & i & "Total").value = 0
        rpt.fields("Bucket" & i & "GrandTotal").value =0
        rpt.fields("Bucket" & i & "Name").value = ""
        rpt.fields("Bucket" & i & "ARPeriod").value = 0
        rpt.fields("Bucket" & i & "ARYear").value = 0
     rpt.fields("ReportTotal").value = 0
    End Sub

    Sub OnDataInitialize
    on error resume next
      for i = 1 to 13
        rpt.fields.add("Bucket" & i & "Total")
        rpt.fields.add("Bucket" & i & "GrandTotal")
        rpt.fields.add("Bucket" & i & "Name")
        rpt.fields.add("Bucket" & i & "ARPeriod")
        rpt.fields.add("Bucket" & i & "ARYear")
    on error goto 0
    End Sub

    Sub OnFetchData(eof)
    dim j

    if IsNull(rpt.fields("BaseAmount").value) = true or rpt.fields("BaseAmount").value = "" then
       msgbox "Bad Value in Base Amount " &  rpt.fields("MemberNumberSorted").value & " " & rpt.fields("BatchNumber").value
       exit sub
    end if

    j = 13
    for i = 1 to 12
       if len(trim(rpt.fields("Bucket" & i & "Name").value)) = 0 then
           j  = i
           rpt.fields("Bucket" & i & "Name").value = "Period " & rpt.fields("ARPeriodNumber").value & "-" & rpt.fields("ARYear").value
           rpt.fields("Bucket" & i & "ARPeriod").value = rpt.fields("ARPeriodNumber").value
           rpt.fields("Bucket" & i & "ARYear").value = rpt.fields("ARYear").value
           exit for
           if rpt.fields("ARPeriodNumber").value = rpt.fields("Bucket" & i & "ARPeriod").value and _
              rpt.fields("ARYear").value = rpt.fields("Bucket" & i & "ARYear").value then
              j = i
              exit for
           end if
      end if
    ' data sorted by ASC date so earliest bucket will be one and latest 12

    rpt.fields("Bucket" & j & "Total").value = rpt.fields("Bucket" & j & "Total").value + rpt.fields("BaseAmount")
    rpt.fields("Bucket" & j & "GrandTotal").value = rpt.fields("Bucket" & j & "GrandTotal").value + rpt.fields("BaseAmount")
    rpt.fields("ReportTotal").value = rpt.fields("ReportTotal").value + rpt.fields("BaseAmount")

    End Sub


  • Replied 4 August 2017, 3:07 pm EST


    Please try to ZIP all files before upload them on this forum. This should prevent all possible problem with uploading.

    I was trying to reproduce the problem you reported with latest build but with no luck unfortunately. Attached is a sample RPX file and RDF file that was got after the this report processing. Could you please take a look at this sample and check if it works fine or not on your side? The results of the report running can be compared with mentioned RDF file. You can correct the attached sample as you need if I missed something and post it here.

  • Replied 4 August 2017, 3:07 pm EST

    Yours worked fine and mine being set up the same way did not.  I am not sure why but I finally got around the problem by using labels instead of text boxes.  I also noticed that it would not allow me to use the label name in a loop. 

    For instance:

    <FONT size=2>rpt.Sections("PageHeader").Controls("lblBucket1Name").caption = "TEST" <FONT size=3>was valid</FONT></FONT>

    <FONT size=2><FONT size=2>for i = 1 to 12

         rpt.Sections("PageHeader").Controls("lblBucket" & i "Name").caption = "TEST"


    <FONT size=3>was not.  Anyway, I got it working.  I attached my final report in case you were curious.  Thanks for your help. I really appreciate it.</FONT>

    </FONT></FONT><FONT size=2> 

    2007/10/csg_Member Spending by Month.zip
  • Replied 4 August 2017, 3:07 pm EST


    Firstly, please make sure you use the latest build from the builds listed by the following link:

    Then if the problem persists, could you please provide a sample of the script code or RPX file completely to take a look how do you set the values of controls?
  • Replied 4 August 2017, 3:07 pm EST


    Please try to do not reference the report's Fields collection in these section events and ReportStart event. The special DataInitialize and FetchData events are the events in which the Fields collection should ever be referenced. You just can read the values from the wrong records.

    Also, please try to do not access to the controls from FeatchData event or from an event that is not one of the three events (Format, BeforePrint, AfterPrint) for the section which contains the control. This can cause strange behavior of the report processing and rendering.
Need extra support?

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

Learn More

Forum Channels