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

running total not working bec of shared variable 2

Status
Not open for further replies.

LMCRYER

Programmer
Jul 30, 2001
388
US
I am in Crystal 9 - report will go into CE9.

I understand exactly what is WRONG but not how to fix it!

OK - report is for fiscal periods, bringing in records and needs to do several different sums (for graphing).

I have 2 tables that are unlinkable (no option of changing them, either)!! 1 is the FCAL (system table with calendar dates and fiscal year / fiscal month info in it) and the other has the data that I need for the report.

I am basically using the FCAL in a subreport (unlinked) to figure out what the currentdate's fiscal year / fiscal month is and then passing that to the main report as a shared variable.

From there, I tried to set a trigger in my detail area of the report to show if the PRD field (which is the Fiscal Yr Fiscal Mo field in the PLGR table) is = to the shared variable that is coming in (to trigger when to start and stop running totals).

Of course, every time I try the running totals it tells me it cant and I know it is because the shared variable is a whileprintingrecords situation -- how the heck do I fix it???

Help! I have to finish this tonight! =(



LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
If that is the barrier, have you tried removing "whileprintingrecords"? No guarantees, but sometimes it turns out not to be necessary.

-LB
 
Hm - here is an idea I think should work -- please share your thoughts...it shouldnt matter if I put that in a subreport or not - I should be able to put that 2nd table in my main report, leave it unlinked, and see what happens since I'm only using it ONCE and its not used for grouping just for evaluating off of something else - would that work?

(I'm trying LB's suggestion now....)

LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
Crystal doesn't have triggers, perhaps you can describe problems using proper technical terms so as not to confuse the issue further.

If you place this FCAL subreport in the report header, then the shared variable will be available anytime afterwards in the main report, inclusive of in a Running Total, so I don't understand the problem here.

Running Totals fuction are at the whileprintingrecords pass.

-k
 
My apologies - I was rambling and not being very clear.

Yes the subreport is in the report header, and the shared variable is available in the report BUT the running total is not accepting the formula that I am trying to put into it that will be used for when it will evaluate.

I am trying to use the shared variable inside of that formula in the running total evaluation and that is where it is telling me it cannot use it.

The "trigger" - bad choice of words on my part. Another option I was trying was using the shared variable in another formula (outside of the running total) that would set to 0 or 1 based on the shared variable and use that 0/1 to determine evaluation (to turn it on or off).






LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
LMC

If you have the sub report in the Report header then this should evaluate before any of the main report has run.

Therefore you don't need WhilePrintingRecords; in the formula used to retrieve the value into the main report.(putthis in report header b) so that it evaluates after the sub report)

In your running totals use this formula rather than referencing the shared variable.

HTH

Gary Parker
Systems Support Analyst
Manchester, England
 
I did exactly as suggested and got rid of the whileprintingrecords, but regardless -- the stupid running total evaluation formula will NOT let me use it (it isnt even listed inside of there when I try to use it!!)

Any other ideas?

LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
I know that you're frustrated, but please try to state specifics.

This "Yes the subreport is in the report header, and the shared variable is available in the report BUT the running total is not accepting the formula that I am trying to put into it that will be used for when it will evaluate.

I am trying to use the shared variable inside of that formula in the running total evaluation and that is where it is telling me it cannot use it."

Should simply and accurately be stated as it is returning the following error: <blah>

And post exactly what you tried.

As you can tell, this does work, so it's likely a minor oversight..

-k
 
Ah. I've calmed and had a smoke - here goes.

shared variable being built in subreport =

// formula name = @curr

shared stringvar curcalc;
curcalc:= IF CURRENTDATE IN {FISCALPRD.BEGIN_DATE} TO {FISCALPRD.END_DATE}
THEN {FISCALPRD.PERIOD};
curcalc

subreport in report header of main report unlinked

formula in main report =
// formula name @curr calc
shared stringvar curcalc;
curcalc

running total evaluation time formula =
{@curr calc} >= {@formatted PRD}

upon trying to run this it states:

A running total cannot refer to a print time formula
details : @curr calc

Does that help?




LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
I tested the following. In the running total, remove the formula reference, and instead use an adapted version of the contents of the formula, as in:

shared stringvar curcalc;

if not onfirstrecord then
val(curcalc) >= val({@formatted PRD})

Please note that (I think) these strings must be converted to values for this to evaluate correctly. You didn't provide the contents of {@formatted PRD}, so if you continue to have problems, I would insert the contents of {@formatted PRD} within val(). Using the formula itself sometimes forces a print time evaluation, so reverting to the contents of a formula can sometimes work when the formula itself won't.

-LB
 
So close, if only you'd shared {@formatted PRD}...

I'd rewrite curcalc:

shared numbervar curcalc;

IF CURRENTDATE IN
{FISCALPRD.BEGIN_DATE} TO {FISCALPRD.END_DATE} THEN
curcalc:= val({FISCALPRD.PERIOD})
else
0

Now it's already a number.

But this probably isn't the problem, I'd guess that {@formatted PRD} is the problem, so try posting that.

Your description was very good though, it describes the report nicely except for that one detail.

-k
 
{@formatted PRD} is a formula that takes a report field and lops off the left character like this:

//@formatted prd
right(totext({ABLUSER_PLGR.PRD},0,'',''),4)



LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
Holy Moly! You both are absolutely awesome. I have no idea why this has been so hard for me but its been a real BOOGER and guess what??? It works!! Thank you so much, greatly appreciated.

Now, for those that might be helped later -- here is what I did:

In the running total Evalute by =
shared stringvar curcalc;

if not onfirstrecord then
val((curcalc)) >= val({@formatted PRD})


and then I simply put in the "Reset" to be right after that to force the ZERO where I needed it like this:

shared stringvar curcalc;

if not onfirstrecord then
val((curcalc)) < val({@formatted PRD})

Wow! What a treat - thanks, guys!

LMC


LMC cryerlisa@hotmail.com

select * from Management where proj_mgmt_skills <> NULL

0 records returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top