[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

CR 2008 Sub-reports sometimes omit data

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"
        ParamField0.CurrentValues.Add(Col0)
        ParamFields.Add(ParamField0)
        Me.myCrystalReportViewer.ParameterFieldInfo = ParamFields
 
        Dim reportPath As String = Application.StartupPath & "\" & "CRReport.rpt"
        Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        rpt.Load(reportPath)
        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

BugReport.JPG
0
purektm
Asked:
purektm
  • 3
  • 2
1 Solution
 
mlmccCommented:
I have never seen this.

Does it happen when you just run a report?

mlmcc
0
 
purektmAuthor Commented:
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).
0
 
purektmAuthor Commented:
It does seem to happen significantly more often (but not exclusively) if I am swapping between reports quickly.
0
 
purektmAuthor Commented:
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.
0
 
mlmccCommented:
I meant does it ever happen when you just run 1 report, no swapping between reports.

Glad you resolved it.

mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now