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

Way to return parameters from sub-report to main report?

Status
Not open for further replies.

jolamb42

Programmer
Aug 23, 2001
26
US
Does anyone know of a way to evaluate a field in the sub-report from the main report? Or to possibly pass that field back as a parameter?

Here is my problem:

Running CR8.5, VB6, SQL server database

I have a sub-report that may or may not display data. I evaluate (and suppress if necessary) each detail line in the sub-report based on some criteria. If the detail line is not suppressed, I increment a RecordCounter formula field. So, if all detail lines are suppressed, my RecordCounter = 0. Otherwise, RecordCounter equals the total number of detail lines that will print in the sub-report.

Since my sub-report has a header that always prints no matter if there are detail lines or not, I cannot use the "Suppress Blank Section" option in the main report. I would like to evaluate the total of RecordCounter in my sub-report from the main report and suppress the section if RecordCounter = 0.

I have tried almost everything. If anyone has any ideas, I would greatly appreciate it!

Thanks!
Jolynn
 
Two things to consider:

1a) to supress the heading in your subreport if there is no data you can either use the Report Option (in the Subreport) of "Supress printing if No Records" or

1b) Suppress the heading section with a supress of IfNULL(Count({table.field})). FI there are nor ecords, the count is NULL and not zero as you'd expect.

2) To get your counter to accumulate values in the subreport and display it abck in the main report use a shared variable.

Formula In Subreport:
Whileprintingrecords;
Shared numbervar MyCounter := MyCounter + Sum({table.recordcounter})
Put it in the report footer and supress

In Main Report to display the value...
Whileprintingrecords;
Shared numbervar MyCounter
 
chelseatech,

Thanks for the tips... one half-way worked!

1a.) The "Suppress printing if No Records" in the sub-report doesn't work because there may be records although none are printed! Remember, I am suppressing detail lines based on certain criteria. The lines that ARE NOT suppressed increments my Record Counter. Thus, if Record Counter = 0, I want to suppress the sub-report (although there may be records not being shown).

1b.) I can't just count all the records and suppress if null (Isnull(count({table.field}). My RecordCounter is a Running Total Field that evaluates each record first and decides whether or not to count it. Therefore, it always starts at 0, not Null.

2.)I have been playing around with the Shared variable idea a lot and I would use it if I could get it to work!!!

In my sub-report, I created a Formula Field Count:
EvaluateAfter ({#RecordCounter});
Shared numberVar Count := Count + {#RecordCounter}

Formula Count then contains the same # as Running Total RecordCounter!

In the main report, I now see my Formula @Count. I edit that to:
WhilePrintingRecords; (I've tried without this line)
Shared numberVar Count

If I display this formula on the report to see what number it contains, it contains zero all the time! What am I missing that the Count formula in the main report is not equal to the Count formula in the sub-report???

Anyone have any ideas???

Thanks!
Jolynn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top