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

CR9: Passing a value to a subreport. 1

Status
Not open for further replies.

MDGarcia

Programmer
Oct 7, 2004
64
PR
Hi everybody.

What I basically want to do is, to pass the value in a field to the subreport to use it in a formula that is used in a running total in the subreport.

I created a shared variable. The formula works fine, but when I ran the subreport the message "A running total cannot refer to a print time formula / Details: @MyFunction" comes up.

I used BeforeReadingRecords and WhileReadingRecords but the formula, apparently, has to be WhilePrintingRecords.

I cannot link this field. I just want to send the value I accept in my parameter form.

Also, I'm doing this with Oracle 9i and PeopleSoft but I don't think this is a problem.

Any Suggestions?

Thanks.
 
You need to show the content of the formula you are trying to pass. You can probably then reference this in a formula in the subreport that uses a variable to do the accumulation, instead of an inserted running total--but you'd have to explain more specifically what you are trying to do for me to help further.

You should specify where you are placing the shared variable formula in the main report, where the subreport is located, the structure of the subreport, what you are trying to accumulate and in what section, and in what sub section you are reporting out the results of the running total.

-LB
 
Hi,
I have quite the same problem.
I have a main report what have fields A,B,C...
and I have a subreport what have a stored procedure as a source, for example MyProc.
I want the subreport to use field A as a parameter for MyProc.
In the database I call the procedure like this:
exec MyProc @ParamA, @ParamB, @ParamC...
I'm using CrystalReport what comes with VisualStudio2005 and the database MSSQL 2005

Ion Filipski
1c.bmp
 
Good day.

The purpose of the report is to present the arrears, payments,and adjustments for a customer's account. The client wants to place the result at the top of the current invoice which, in the main report, is on the group header area.

I link both reports by customer account and other 3 fields.

The structure of the subreport is like this:
Group header by Customer: suppressed

Details: suppressed. I include the subreport's fields on this section.

Group footer by Customer containing the running totals for the balances, payments and other adjustments for all outstanding invoices.

The running totals are the sum of the amounts Evaluated by the transaction code. The problem is with the payments and adjustments.

I want to pick those payments and adjustments posted in a 30 day period. I need to subtract the invoice date in the main report with the accounting date of the payment/adjustment transaction on the subreport.

I am trying to pass this date value as shared,and it won't work. I created a formula with a shared value on the main report as follows:

//@fnSharedDt:
Shared dateVar dtNewInv := {QUERY.INVOICE_DT};

On the subreport I created a formula to capture this value:

//@fnDteFormula:
Shared dateVar dtNewInv;
dtNewInv

I place this value on the details section.

Hope this helps. I am checking your resolution, I think I know what you mean.

Thanks.
 
You didn't explain the group structure of the main report, or in what section the subreport is located. What are the other three fields you are linking on in the sub?

Note that for the shared variable to be used in the sub, the sub must be placed in a section lower than the one in which the main report shared variable formula is located, so if in the main report the formula is in GH#1a, the sub should be in GH#1b or in the GF#1 footer. You could then create formulas to replace the running totals, like:

//{@accum} to be placed in the detail section:
whileprintingrecords;
shared datevar dtNewInv;
numbervar sumamt;

if datediff("d",{table.transdate},dtNewInv) > 30 and
{table.transcode} = 123 then
sumamt := sumamt + {table.amt};

//{@display} to be placed in the subreport footer:
whileprintingrecords;
numbervar sumamt;

You might need a reset formula that sets the variables to zero--depends upon how you are linking the sub to the main.

-LB
 
LB:

Thank you very much for your last resolution. I actually substituted 3 running totals with code similar to yours and it's working very well.

You deserve a star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top