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

problem with EvaluateAfter

Status
Not open for further replies.

mperera

Technical User
Sep 7, 2001
20
0
0
US
Hi,

I've got a formula (formula2) which needs to be evaluated after formula1 to return the correct results.
Formula2 looks something like this:

evaluateAfter({@formula1});
if {ACCOUNTS.STATUS} = 'LAST' then
(local stringvar returnval := ' ';

if not isNull({ACCOUNTS.FIRSTNAME}) then
returnval := returnval + {ACCOUNTS.FIRSTNAME} + ' ';
if not isNull({ACCOUNTS.LASTNAME}) then
returnval := returnval + {ACCOUNTS.LASTNAME + ' ';

if returnval <> ' ' and length({@formula1}) = 0 then
returnval := 'NAME=' + returnval;

trim(returnval)
)

The formula should only add the 'NAME=' text in the return value if formula1 is blank. However, it seems to be adding that text even when formula1 is not blank (and testing has shown me that within the if statement, formula1's value is always blank). Any thoughts on what I'm doing wrong here?

Thanks.
 
Three things...

1. Are {@Formula1} and {@Formula2} on the same section? or does {@Formula1} follow on a lower section? They shud be on the same section for the EvaluateAfter to work

2. Try adding &quot;WhilePrintingRecords&quot; to all formulas used for display (not the ones used for grouping) this makes sure they are evaluated at the right time.

3. Try Length(trim({@formula1})) instead of length({@formula1}) there may be a blank space sneaking in there somehow and the trim will remove it.

Hope this helps
Jim
 
Jim, Thanks.

I added WhilePrintinRecords immediately before the EvaluateAfter...

The formulas are in different detail sections, but I don't think that is the problem. For example, I modified formula2 to simply return the output of formula1, which is does properly. However, as soon as I add the if statement, and try to reference the value returned by formula1, it's as if formula1 has not yet been evaluated. I don't see what it is about the if statement which is causing formula2 to 'lose' the value of formula1.

Thanks again.
 
Hmmm...on re-read, it is BECAUSE @Formua1 has the value of null that the IF statement is failing.

Try this instead of using Length

if returnval <> ' ' and IsNull({@formula1}) then
returnval := 'NAME=' + returnval;

if there is a possiblity that {@formula1} can be equal to a single space And you want this to evaluate as though it were null then

if returnval <> ' ' and (IsNull({@formula1}) or
Length(trim({@formula1})) = 0) then
returnval := 'NAME=' + returnval;

Should also work....Crystal does not like NUll's in IF statements without being tested with IsNULL

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top