Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport fails to display second page 1

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
0
0
US
Hi all...

I have a very interesting and frustrating problem. Here it goes: I have a Crystal report that has a subreport. I'm testing the report with a given set of data for which the subreport is supposed to display two pages. When I preview the report, I see the first page and all is good. But when I click next, I get an empty page.

Now, hear this: If I double click on the subreport while I'm on the first page, I go to the subreport preview and the data is all there. I can see both pages and everything is correct. However, for some strange reason, I cannot see both pages when I'm previewing from the main report.

This is driving me insane! I have been working with this for like a week and haven't been able to solve the problem.

I use a command to grab the data. There are 26 records being retrieved from the database and I know (and I can see) exactly what is being retrieved - I know each record inside and out. The data is correct and everything seems to be in place.

Now I discovered that when I click next, a shared variable which is in charge of hiding/displaying some sections of the subreport is becoming null. I believe this is where the problem lies, but I have gone through every single little formula, section, detail, etc, and there's no reason whatsoever why this variable should become null.

Can anyone shed some light? Other subreports in the same report are formatted in exactly the same way and they display correctly.

I'm running Crystal Reports XI R2 on a Windows XP Pro machine. I'm using .NET 2008 Professional, and I use MySql 5.0 as my database.

If you need more details, please let me know.

Thanks.

_________________________________
I think, therefore I am. [Rene Descartes]
 
If vars are going null, use an initialise formula in appropriate header to declare them with a value.

If there is a danger of them being over written as Nulls, then in your var evaluate formula add a conition that makes sure Var stays as default when it encounters a null.

Ian

 
Thanks Ian...

I have appropriate init/reset formulas in place, but they're not helping. Also, I'm not sure if this doesn't explain why the second page of the report is not showing up when I hit "Next Page" on the main report.

Here's a bit more info: The report is required to display the total count and percentage of a number of items in the database. Items must be displayed next to each other (as opposed to going down). Thus, if I have 3 items, the report must show 3 columns, Item 1, 2, and 3 (actually 5, because I need I need description and total). You can think of it as a complex cross tab which I must create manually.

The variable that determines how many columns there should be, is actually a formula on the main report which is linked to a parameter on the subreport. This formula simply returns the UBound of a shared array variable. So we have three things here: 1 - a formula on the main report, 2 - a parameter on the subreport, and 3 - a shared array variable. Again, the formula on the main report simply returns the UBound of the shared array variable and this value is linked to a parameter in the subreport.

On the first page of the report, all is working fine, but when I click next, it appears the output from the formula on the main report (1 above) is not linked properly to the subreport parameter and thus the parameter in subreport (2 above) becomes null. There's no code anywhere that changes the shared array, so the output of the formula on the main report should never be null. Also, when the parameter becomes null I can still see that the shared array has all it's values and its UBound returns a proper value. So the problem appears to be in the linking between the formula in the main report and the parameter in the subreport.

Now a good question would be why on earth am I using a parameter on the subreport if I can simply use the shared array variable and get its UBound? That's because originally I only needed the parameter (not the array). Later on, the report requirements changed and I added the array and didn't want to go ahead and replace the many many references I had to the parameter. I can definitely replace the parameter for a variable declaration and the use of UBound, but I'm not sure that's going to solve anything right now.

Thanks.

_________________________________
I think, therefore I am. [Rene Descartes]
 
Remove conditional suppression of sections and add a formula to sub report and test elements of your array.

ie make sure they are being passed and working in .

Ian
 
Ian thanks again...

The elements of the array are being passed in correctly. I can check that like this:

Code:
shared stringvar array arr;
local numbervar i;
local numbervar j;

if ({?subreportPar}) then (
   i := 0;
   j := 1/i
)

{?subreportPar} is the parameter of the subreport that is linked to the formula in the main report which returns UBound(arr). If the parameter in the code above is null, then Crystal Reports will obviously throw an exception and stop at the line j := 1/i (as this is division by zero). At that point, I can inspect all variables in the formula and I can see that the array has proper values, but the parameter is null.

The big question I have is this... How come I can't see the second page of the subreport when I click next? Why is that happening? I mean, when I double click on the subreport I can clearly see that it has 2 pages, and I can click next and see the second page. However when I click next from the main report, I don't get the second page of the subreport. Instead, I'm getting another instance of the subreport which contains the null value in the parameter above.

What can cause that to happen? It is driving me insane.

Thanks again.

_________________________________
I think, therefore I am. [Rene Descartes]
 
Does the report display and run correctly outside of your .NET application?

If yes then your applications is blocking the view of page two.

Ian
 
I'm testing the report on Crystal Reports by itself. The .NET application accesses the report later, but they are designed and tested on the standalone Crystal Reports XI R2.

Thanks.

_________________________________
I think, therefore I am. [Rene Descartes]
 
Ok, I found something. Not the solution, but at least it provides some insight as to what's going on.

My main report contains a total of 3 subreports and are respectively placed on three sections of the main report: GF1a, GF1b, and GF1c. Depending on the type of data being retrieved from the database, a different section (and hence a different subreport) is displayed.

Now, two of the subreports are extremely similar. In fact they're exactly the same except for the fact that one of them retrieves data from one table in the database while the other gets data from a different table and some other minor details. This being the case, what I did when I was creating the second subreport is I selected "Save Subreport As" and saved it, then re-imported it and made the appropriate changes to the database command, formulas, etc.

Well, there appears to be some kind of link between the two reports now. If I delete any of the two, the other one works perfectly, but when I have both, only one of them will work. Which one? Whichever is physically first on the main report. If I change the order of the sections, whichever of them ends up being first will run correctly, while the other will have the issues I speak of above.

I tried deleting the subreports and renaming them, but that does not help. I don't want to recreate either of them from scratch because that would take too long - they have well over 100 sections (with lots and lots of physical objects which must be correctly aligned to provide that multiple-column stuff I was talking about above).

Does anyone have any idea why this is happening?

Thanks.

_________________________________
I think, therefore I am. [Rene Descartes]
 
In format subreport have you turned off "ReImport when opening"

Just clutching at straws!

Ian
 
Thanks Ian - really appreciate it.

The "re-import when opening" option is off.

Don't you find it weird that if I delete one of the two subreports, the other one works perfectly, but if I keep both, only one of them (the first one from top to bottom) works? Does that ring any bells?

_________________________________
I think, therefore I am. [Rene Descartes]
 
Have you renamed VARS so completely different names in each sub report.

Could be that shared vars from one subreport are interfering with same vars in your copied/modified report?

Not seen anything like the problem you have described!

Ian
 
IanWaterman said:
Have you renamed VARS so completely different names in each sub report.

Could be that shared vars from one subreport are interfering with same vars in your copied/modified report?
Right on the money, man. Thanks again for all the help.

_________________________________
I think, therefore I am. [Rene Descartes]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top