CR 2008 Sub-reports sometimes omit data

Posted on 2009-02-10
Last Modified: 2012-05-06
Summary: Sometimes sub-reports get all of the necessary parameters, but don't populate data.

I am using Crystal Reports 2008 to report data from a MS Access database in a VB2005 program.

When the form with my report viewer loads, it runs through the logic to set different parameters, which are then attached to the report viewer.  The (main) report is then loaded.

The main report features 5 sub-reports, 4 of them identical, except for parameters passed along.

Now, the titles of the sub-reports are controlled via parameters (linked from main to sub).  The sub-reports may be suppressed via parameters (in the main report).  And the data in the sub-reports is controlled via parameters (database connection using linked parameters...).

The suppression works 100% of the time.  The titles work 100% of the time.  The sub-report data usually works, but every once in a while the body of one or more of the sub-reports goes missing.

I can usually recreate this by switching between different reports and opening one, close, open the other, close - repeating until one bugs.  Hitting the "Refresh" button on the Crystal Report Viewer will fix that instance of the problem, but I'd like to eliminate it completely.

As it appears that the parameters are always getting where they need to go (the sub-reports titles feature the correct/current info) I'm not sure what code would be necessary.

Thanks in advance for the help.
Example Code to show Methodology:

    Public ParamField0 As New CrystalDecisions.Shared.ParameterField

    Public ParamFields As New CrystalDecisions.Shared.ParameterFields

    Public Col0 As New CrystalDecisions.Shared.ParameterDiscreteValue

'  Logic

'    Col0.Value = -1, 0, or some positive Integer

        ParamField0.Name = "Col0"



        Me.myCrystalReportViewer.ParameterFieldInfo = ParamFields

        Dim reportPath As String = Application.StartupPath & "\" & "CRReport.rpt"

        Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument


        Me.myCrystalReportViewer.ReportSource = rpt

'     The report itself uses a combination of its parameters and an Access Query to fill out the

'            fields on the main form.

'     The report looks at Col0.  If it is -1, it suppresses one of the sub-reports, if not, it 

'             passes that parameter to that sub-report.

'     The sub-report takes the value of Col0 and names the title accordingly.

'     The sub-report accesses an Access table using Col0 (and other parameters) to 

'             filter results.

Open in new window

Question by:purektm
    LVL 100

    Expert Comment

    I have never seen this.

    Does it happen when you just run a report?


    Author Comment

    I guess I'm not 100% clear on what you're asking.

    It happens when I simply generate a report with my program, though there are several processes at work there (as outlined above).

    Author Comment

    It does seem to happen significantly more often (but not exclusively) if I am swapping between reports quickly.

    Accepted Solution

    I wasn't properly disposing of my reports (something my speed tests eventually revealed) - while I'm not 100% sure why missing a dispose caused blank sub-reports, properly disposing seems to have eliminated the problem.

    Thanks for reading.
    LVL 100

    Expert Comment

    I meant does it ever happen when you just run 1 report, no swapping between reports.

    Glad you resolved it.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now