crystal report - variable not working in formula

I have a shared data variable in a subreport that I am bringing over to the main report.  This is working perfectly until I try to use the variable in a formula.  As soon as I put the variable in the formula, the values of the variable disappear.  

I have the variable reset in section Footer 1a:

whileprintingrecords;
Shared datevar cldate;
cldate:= date(0,0,0);


The subreport in Footer 1b setting the value,

whileprintingrecords;
Shared datevar cldate;

if {ARPAHIST.ARPAHARRDTE}<{ARACCOUNT.ARACLSTDTE}+31 and {ARPAHREL.ARPRLACTIVE} = "Y" then
    cldate:= currentdate
else
(
if ({ARPAHIST.ARPAHARRDTE}<{ARACCOUNT.ARACLSTDTE}+31) or (not(isnull({ARACCOUNT.ZZARACNEWESTLSTDTE})) and {ARPAHIST.ARPAHARRDTE}<{ARACCOUNT.ZZARACNEWESTLSTDTE}+31) then
    (if isnull({ARPAHIST.ARPAHCLSDTE}) then
    cldate:= {ARPAHIST.ARPAHBRKDTE}
    else if isnull({ARPAHIST.ARPAHBRKDTE}) then
     cldate:= {ARPAHIST.ARPAHCLSDTE})
else if {ARPAHIST.ARPAHARRDTE} = cldate then
    (if isnull({ARPAHIST.ARPAHCLSDTE}) then
    cldate:= {ARPAHIST.ARPAHBRKDTE}
    else if isnull({ARPAHIST.ARPAHBRKDTE}) then
     cldate:= {ARPAHIST.ARPAHCLSDTE})
)

;


I'm displaying the variable in Footer 1c:

whileprintingrecords;
Shared datevar cldate;

cldate

This works fine until I try to use the display field in part of an IF statement for the Fee field -  if ({AFTRANSACTION.AFTREFFDTE} <= {@DisplayCloseDate}) then 12.  The formula doesn't calculate to 12 when it should and the data in the DisplayCloseDate gets wiped out.
altosaxAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
Try changing the FEE formula to

whileprintingrecords;
 Shared datevar cldate;
 if ({AFTRANSACTION.AFTREFFDTE} <= cldate ) then 12

Open in new window


mlmcc
0
altosaxAuthor Commented:
My variable shows up in my display formula now but the Fee does not change to 12 when it should.
0
mlmccCommented:
Can you upload the report file?

mlmcc
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

altosaxAuthor Commented:
No, it has NPI in some formulas.
0
mlmccCommented:
WHere did you put the FEE formula?

mlmcc
0
altosaxAuthor Commented:
Footer 1c
0
James0628Commented:
When you say "Footer 1x", I assume you mean "group footer 1x" (as opposed to the report footer) ?

 In your first post, you said "This works fine until ...".  So, that third formula displays the correct value for cldate at first?

 Is @DisplayCloseDate that third formula, or something else?

 That third formula and the "Fee field" are both in "footer" 1c ?

 James
0
altosaxAuthor Commented:
1. Yes - group footer.

2. cldate is now displaying correctly at all times.  It's the fee field that now shows up correctly at first until I put it into another field Fee Amt     (({AFSPLIT.AFSPAMT}*-1) * {@Fee})/100.  As soon as I do this, the Fee field changes to 10 which is the default:
            if ({AFTRANSACTION.AFTREFFDTE} <= cldate) then
            12
            else
            10

3. DisplayCloseDate:
whileprintingrecords;
Shared datevar cldate;

cldate

4. DisplayCloseDate, Fee, and Fee Amt are all in Footer 1c
0
James0628Commented:
Do all 3 formulas include WhilePrintingRecords?  I don't think the formulas that use the shared variable really need it (I think using a shared variable puts them in the "printing" pass), but if the FeeAmt formula doesn't use any shared variables directly, I'd include WhilePrintingRecords, for consistency, if nothing else.

 If that doesn't help, you could try adding EvaluateAfter ({@Fee}); to the beginning of the FeeAmt formula.  It doesn't seem like it should be necessary, but I'm not positive about that.  Might as well try it and see what happens.

 James
0
altosaxAuthor Commented:
I tried both of these suggestions and the Fee field is still showing 10 for everything.
0
James0628Commented:
Based on what you've said, I don't know why the value would be changing, so I think we're missing something somewhere.  But without being able to see the report, with the formulas and how and where they're used, I don't know what that might be.

 James
0
mlmccCommented:
Could you build a report with just those formulas and see if it has the same issue?
If it does then perhaps that report could be uploaded.

mlmcc
0
altosaxAuthor Commented:
I created a field in our system for the cldate variable.  That way I didn't have to calculate it in the report, I just pulled the date from our system.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
altosaxAuthor Commented:
Because of NPI in my report, I was unable to upload my report for further help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.