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?
 
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
 
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
mlmccCommented:
Can you upload the report file?

mlmcc
0
 
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:
Because of NPI in my report, I was unable to upload my report for further help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.