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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Values from Subreport to Main Report 1

Status
Not open for further replies.

marlow1208

Technical User
Nov 6, 2008
16
US
I am attempting to pass values from subreports to the main report and the resulting values are 0 rather that the correct value. Where is my error?

I am using a main report that contains 4 subreports. Each subreport contains a formula that creates a shared variable.

The formula in each subreport is as follows:

Subreport 1 CMMTDOpen formula:
Whileprintingrecords;
Shared NumberVar CMMTDOpen;
CMMTDOpen := Count({MEM_MEMBER.MEM_ID});

Subreport 2 CMYTDOpen formula:
Whileprintingrecords;
Shared NumberVar CMYTDOpen;
CMYTDOpen := Count({MEM_MEMBER.MEM_ID});

Subreport 3 HCMTDOpen formula:
Whileprintingrecords;
Shared NumberVar HCMTDOpen;
HCMTDOpen := Count({MEM_MEMBER.MEM_ID});

Subreport 4 HCYTDOpen formula:
Whileprintingrecords;
Shared NumberVar HCYTDOpen;
HCYTDOpen := Count({MEM_MEMBER.MEM_ID});

Each subreport is located in the details sections of the report.

I am attempting to pass each value to the main report using the following formulas in the main report:

Main Report CMMTDOpen formula:
Whileprintingrecords;
Shared NumberVar CMMTDOpen;

Main Report CMYTDOpen formula:
Whileprintingrecords;
Shared NumberVar CMYTDOpen;

Main Report HCMTDOpen formula:
Whileprintingrecords;
Shared NumberVar HCMTDOpen;

Main Report HCYTDOpen formula:
Whileprintingrecords;
Shared NumberVar HCYTDOpen;

I have placed the four formula fields in the main report in the last detail section of the report.






 
The formulas must be in a section after the one containing the subreports, e.g., in detail_b if the subs are in detail_a.

You also cannot suppress the section containing the subreport or the subreport objects themselves. If you want the section containing them not to show, then suppress all sections WITHIN the subreports, format each subreport in the format subreport->subreport tab to "suppress blank subreport", remove the borders around the subs, and then in the main report, go into the section expert and select the section containing the subs->check "suppress blank section".

-LB
 
I currently have a subreport in sections Detail B, Detail C, Detail F, and Detail G. I placed the formulas in Detail H and it did not work.

I tried it again by placing all four subreports in Detail B and the formulas in Detail C. This did not work either.

Any suggestions on what else could be the problem?
 
What do you actually get? As a diagnostic, try displaying the values in both the subreport and the main report. And the orignal fields, often it is the original data that is not what you expected.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
I get a value of 0 for all formulas in the main report. When I use the variables in the subreports, I get the correct values.
 
So are you suppressing or hiding the subreports or the sections in which they are located?

If not, are the subreports linked to the main report? I would check the links as a next step.

-LB
 
I am not suppressing any sections of the report. However, I do see that the subreports are not linked to the main report as you suspected, and I assume this is the problem. Unfortunately, I have been unsuccessful in trying to link them, as I am not familiar with it.
 
They don't HAVE to be linked--it depends upon the logic. If the subreports are NOT linked, they should show data if placed in the detail section of the main report. Can you see the subreport data? I mean the subreport content itself, not the shared variable formula.

-LB
 
Yes, I see data in the subreports. Everything works and displays exactly as it should except for the shared variable value in the main report.
 
Make sure that the variables are all identified as "shared" in both main report formulas and subreport formulas and that the variable names are the same.

If the subs aren't suppressed and the section they are in isn't hidden or suppressed, and the main report formulas are in a lower section, I cannot see a reason for the formulas not to display. Did you add any reset formulas for the shared variables? If so, where are these placed?

-LB
 
It is working now. I created all the variables correctly, but I didn't actually use the variables in the subreports. Once I placed all of them in the subreports, they calculated corrected in the main report.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top