Report unpredictably picking up data form next record and reporting incorrect results

Posted by: ricwha on 4 August 2017, 6:11 am EST

  • Posted 4 August 2017, 6:11 am EST

    I have attached a copy of a report and its sub reports which is producing an unusual issue. The report seemingly runs correctly then out of the blue either the Category sub report or the Key Element one will report information form the next contract (database record). The subsequent record reports correctly.







    We have tried changing the can grow and shrink option to no avail. If however we align all sub-reports on the same line the issue appears to go away. I can’t say it’s corrected for sure because the report is large and when we have tried other placements of the sub-reports different records start to report incorrectly and the incorrect one seems to fix itself. We have tried a page break at the end of each detail and that works unless one of the notes is really long—forced that way for testing. The last option is in the short term usable, but here too we cannot provide any assurance that it is 100% correct. We have also tried moving the cursor to the client as well as altering the cursor type with no change in behavior noted.







    This is a user report that they run quarterly against 5000 records—SQL2000 database. Naturally none of us are too happy about the unreliability of the report being generated. We are running the Professional Edition build 2.5.0.1309. I have looked at the details for 1314 and unless it’s known there is something there that specifically corrects this we prefer not having to distribute it right now.







    I can provide a test database if comes to that. Any suggestions concerning what more to look into





    2008/06/ZymogeneticsOriginalReport.zip

  • Posted 4 August 2017, 6:11 am EST

    Could you please provide the codebehind of your reports?  I would like to see if there is any code present which might cause this behavior.

  • Posted 4 August 2017, 6:11 am EST

    I have attached the code that is executed when the report starts. There is no report interaction after that. What we see is the report tools along a record is partially invalid–gets the next records data then runs ok until the next random error.







    There are two chucks of code here> The first is used to get the rpx file and add in the connection string which we remove from the report. The second is a class used to populate the sub-reports with the correct connection information. The only scripting is in the rpx I sent you and is used for the run dat of the report.











    Public Sub OpenCustomReport()



    Dim arDataControl As DataControl



    Dim objLink As New clsSubRptLink



    Dim intLoadError As Integer







    With frmContractMain.CommonDialog1



    .FileName = vbNullString



    .Filter = “Custom Report Files (.RPX)|.rpx”



    On Error GoTo ERRORCON



    .ShowOpen



    On Error GoTo 0



    If .FileName <> vbNullString Then



    Set garCustomReport = New DDActiveReports2.ActiveReport



    garCustomReport.LoadLayout (.FileName)



    'Link all Subreports for Main Report. NOTE: code to resolve sub reports must be here to work



    garCustomReport = objLink.StaticSubLink(garCustomReport, gstrSQLProvider, caFileServices.ParsePath(.FileName, parDrvDir), intLoadError)



    If intLoadError = 2 Then



    Exit Sub



    End If



    Set arDataControl = garCustomReport.Sections(“Detail”).Controls(“dc”)



    If InStr(1, arDataControl.ConnectionString, gcstSecureAccess) Then



    arDataControl.ConnectionString = gstrSQLProvider



    ElseIf InStr(1, arDataControl.ConnectionString, gcstDbProvider) Then



    arDataControl.ConnectionString = gcstDbProvider & gstrInitialAppPath & gcstReportDbName



    Else



    MsgBox MSG01, vbApplicationModal + vbExclamation + vbOKOnly, “Open Custom Report”



    Unload frmCustomReportViewer



    Exit Sub



    End If



    End If







    If .FileName <> vbNullString Then



    Unload frmCustomReportViewer



    frmCustomReportViewer.Show



    End If







    End With







    Exit Sub







    ERRORCON:







    If ERR <> cdlCancel Then



    MsgBox ERR.Description



    End If







    End Sub











    Option Explicit



    Const cstRepStr = “”



    Const cstRepPath = “”



    Const MSG01 = "Warning! Could not find a data control on the subreport " & cstRepStr & ". This may or may not be a problem although an ADO control would normally be present. Processing will continue. "



    Const MSG02 = "The sub-report " & gcstQuote & cstRepStr & gcstQuote & " could not be located in file path " & gcstQuote & cstRepPath & gcstQuote & “. Request has been cancelled. Check to be certain that the missing sub-report is located in the designated path.”



    Const MSG03 = “Load sub-report”







    Public Function StaticSubLink(objReport As Object, _



    ByVal strConnection As String, _



    ByVal strSubRptPath As String, _



    intErrorLvl As Integer, _



    Optional bolReprotError As Boolean = True) As Object







    Dim rptSet As Object



    Dim objCtl As Object



    Dim objCtl2 As Object



    Dim ardcDataControl As DataControl







    'This loop process every rptSettion looking for any subreport controls



    'Once it Finds a Subreport Control it loads the RPX File that is stored in the SubreportControl.ReportName



    'After the Subreport object is loaded it sets SubreportControl.Object to the Subreport Instance







    intErrorLvl = 0



    For Each rptSet In objReport.Sections



    For Each objCtl In rptSet.Controls



    If TypeName(objCtl) = “SubReport” Then



    If objCtl.ReportName <> vbNullString Then



    Set objCtl.object = New ActiveReport



    'Set objCtl.object = New DDActiveReports2.ActiveReport



    On Error GoTo LOADFAILED



    objCtl.object.LoadLayout strSubRptPath & objCtl.ReportName



    On Error GoTo 0



    End If



    On Error Resume Next



    ERR.Clear



    'Populate the subreport with the same connection sting as used in the main report



    'If the ConnectionString missing can cause a fso.delete delete to later on throw a malicious script error



    Set objCtl2 = objCtl.object.Sections(“Detail”).Controls(“dc”)



    If ERR.Number = 0 Then 'If no control issue warning but continue. Sub report may be static information



    Set ardcDataControl = objCtl2



    ardcDataControl.ConnectionString = strConnection



    Else



    intErrorLvl = 1



    If bolReprotError Then



    MsgBox Replace(MSG01, cstRepStr, objCtl.ReportName), vbInformation + vbApplicationModal + vbOKOnly, MSG03



    End If



    End If



    On Error GoTo 0



    End If



    Next



    Next







    'Return the new report object



    Set StaticSubLink = objReport







    Exit Function







    LOADFAILED:







    intErrorLvl = 2



    If bolReprotError Then



    MsgBox Replace(Replace(MSG02, cstRepPath, strSubRptPath), cstRepStr, objCtl.ReportName), vbApplicationModal + vbExclamation + vbOKOnly, MSG03



    End If







    Set StaticSubLink = objReport 'Doing this avoids an error







    End Function

  • Posted 4 August 2017, 6:11 am EST

    So far, I haven’t seen any code which would cause this behavior.  I would just like to confirm that there is no codebehind for the reports, since everything is set up before the main report runs.



    If possible, could you please provide a sample application which reproduces this behavior?

  • Posted 4 August 2017, 6:11 am EST

    This is not going to be easy for you so le t me be certain you understand what I’m going to have to send you.







    You will need one of our test SQL databases, probably SQL2000. The issue is that the problem can bounce around but I think we have an example where it will repeat itself at a set location–record. I’ll have to send you our copy the report designer because it uses controls that you won’t have. I can explain how to logon. I suspect it’s with the RTF control because the report gets botched after one of these executes. Moving the order of the sub-reports jumps the issue elsewhere. If it doesn’t fail where we point you to look it may be it always hits someplace else. The problem is you have to look record by record. We have spent days on this so I know how frustrating this may be.







    Believe it or not this is the quickest path to getting this in your hands.







    Our I can have you go online with us and look at what we have as well as let you poke around if you like.







    How would you like to proceed?



  • Posted 4 August 2017, 6:11 am EST

    I would like to take a look at the sample application.  It would probably be better to have the actual application in our hands, so that we can run it against the source of ActiveReports if necessary.  Also, I could get a few sets of eyes on the project if needed.



    If you like, you can post the sample here, or send it to support@datadynamics.com if you don’t feel comfortable posting it on the forum.

  • Posted 4 August 2017, 6:11 am EST

    I will probably have it to you tomorrow if not late today. I will send you a download link to our FTP site at the mentioned email address or yours specifically if you like. I prefer not to post our database as it does contain some stuff we prefer not to distribute in an open forum. The code executing the report is as I have shown you. You already have the RPX files. The data abase is fairly well compacted. More information will be in the email I send you.







    I am going to be running the same report through the AR 3 .Net version of our Report Designer to see if it shows similar behavior. If the issue recurs whether the problem is in AR or something we are doing it may give us the opportunity to address it in two places.



    .

  • Posted 4 August 2017, 6:11 am EST

    I have sent a seperate email to you with everything you will need. It does have two download links in it. Should these not get through to you let me know. Some mail systems will remove them.

  • Posted 11 April 2018, 6:05 am EST

    Did you ever figure out the issue? We are having a similar problem where a subreport is picking up data from a different record than expected. If the underlying data changes such that a different number of rows is returned, the problem disappears. Frustrating. This was an issue even in ancient AR 2.0 but we never figured it out. We are on AR10 now and assumed the issue was fixed given that many versions.

Need extra support?

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

Learn More

Forum Channels