cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Reports - empty Data Fields after page break

0 Kudos

I am modifying an existing Crystal reports file. We use CR 2008. No, I am not allowed to update

The Report gets it´s data from C#. We are mostly working with formulas and get the data from an Oracle database. The Report has two Subreports. Every formula and Subreport is inside the same Section.

I have here a working Report. I did add some formulas to it. Previously everything was on one page, but now everything is too squished. That´s why I have dragged one Subreport further down, so that the program automatically makes a page break.

I did NOT modify the Subreport at all. I did only change it´s position.

The problem is when I do this, the formula fields on the new page are empty. The same happens if I add a new Section, add this Subreport to it and tell the previous Section to make a page break after. When I now go back and drag the Subreport up, so that it fits on one page, the data will be filled.

Curiously, when I drag the first Subreport to the second page it´s data will be shown. And if the 2nd Subreport has only one line on the first page, but all other lines on the second it shows all the data too.

Also, this only happens in our own software, when I use the CR Viewer then the data on the second page is there.

I have already debugged through the corresponding code and there I can see that for the Main Report and all the Subreports the Datasources will be set.

So, I do not believe that it´s a C# problem.
I have checked if there is something like an "Page" object, which I have to use for more than one pages, but appparently there is not. Also, the other Subreport does not need it either.

Here we go:

<code> if (this.cryRpt != null)
        {
            this.cryRpt.Close();
            this.cryRpt.Dispose();
        }            
        this.Cursor = Cursors.WaitCursor;
        this.Refresh();
        if (stuff())
        {
            string file = path + file;
            if (System.IO.File.Exists(file))
            {
                cryRpt = new ReportDocument();
                TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
                TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
                ConnectionInfo crConnectionInfo = new ConnectionInfo();
                ConnectionInfo crConnectionInfo2 = new ConnectionInfo();
                Tables CrTables;                   
                try
                {                       
                    cryRpt.Load(path + file);
                  
                    crConnectionInfo.ServerName = blaaaa;
                    crConnectionInfo.DatabaseName = "";
                    crConnectionInfo.UserID = blaaa;
                    if (check == null)
                    {
                        blaaa.object.CrPW = "";
                    }

                    crConnectionInfo.Password = blaaa;
                    crConnectionInfo.AllowCustomConnection = false;
                    crConnectionInfo.IntegratedSecurity = false;

                    crConnectionInfo2.ServerName = blaaa;
                    crConnectionInfo2.DatabaseName = "";
                    crConnectionInfo2.UserID   =  blaaa;                      
                    crConnectionInfo2.Password = blaaa;
                    crConnectionInfo2.AllowCustomConnection = false;
                    crConnectionInfo2.IntegratedSecurity = false;
                   
                    CrTables = cryRpt.Database.Tables;
                 
                    cryRpt.ReportOptions.EnableSaveDataWithReport = false;
                                                             
                    // Set Logon to all SubReports
                    foreach (ReportDocument subreport in cryRpt.Subreports)
                    {
                         foreach (Table table in subreport.Database.Tables)
                        {
                           
                            TableLogOnInfo logOnInfo = table.LogOnInfo;
                            crtableLogoninfo = table.LogOnInfo;
                            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                            table.ApplyLogOnInfo(logOnInfo);                              
                        }
                    }

                    // Logon to Mainreport
                    foreach (Table table in cryRpt.Database.Tables)
                    {                           
                        TableLogOnInfo logOnInfo = table.LogOnInfo;
                        crtableLogoninfo = table.LogOnInfo;

                        if (table.Name == "blaaa4" ||
                            table.Name == "blaaa3" ||
                            table.Name == "blaa2" ||
                            table.Name == "blaaa1")
                        {

                            crtableLogoninfo.ConnectionInfo = crConnectionInfo2;
                        }
                        else
                        {
                            crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                        }                          
                        table.ApplyLogOnInfo(crtableLogoninfo);                                                     
                    }
                    crystalReportViewer1.ReportSource = cryRpt;
                  
                    if (chk_50.Checked == true)
                    {
                        crystalReportViewer1.Zoom(50);
                    }
                    else
                    {
                        crystalReportViewer1.Zoom(100);
                    }                      
                    crystalReportViewer1.Refresh();
              
                    strip_info.Text = "<" + str_name + "> successfully created!";
                }

Accepted Solutions (1)

Accepted Solutions (1)

DellSC
Active Contributor
0 Kudos

You could try turning off "Keep Together" for the subreport and see whether it will just naturally flow to the next page. If you want repeated column headers headers on the next page, here's how you simulate page headers in a subreport:

1. In the subreport, group on something that only has a single value in the subreport. This is usually a linking field.

2. For the group, turn on "Repeat Group Header on Each Page".

3. Move any headers from the report header to this group header section.

-Dell

0 Kudos

You mean in the Subreport in the data Section? This is greyed out.

Or is there a "keep together" for the full Subreport?

No, those are not the same Headers/data as in the first page, so I don´t really need that.

But still... is it not possible to do this with only Textfields?

Thanks.

DellSC
Active Contributor
0 Kudos

Right-click on the subreport object in the Main report to modify "Keep Together".

-Dell

Answers (0)