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

If conditions unexpectedly return blank instead of true, false

Status
Not open for further replies.

wooddrove

IS-IT--Management
Jan 25, 2002
3
US
I have a formula with multiple groupings in the report, at the lowest level grouping, the "items", I have a formula with an if statement giving me problems.

Here are my main sections in the report:
office group header
dept group header
jobtitle group header
userid group header -> variables reset here
items number header
details (empty)
items footer -> main formula and test formula here
userid footer -> output string formula and user info here
jobtitle footer
dept footer
office footer


For most userid's the formula creates a running total string for the items belonging to a particular user. The total for the string is printed out for each user in the user group footer and then reset for the next user in the group header for the user group.

The running total doesn't need to calculate if the user has a certain jobtitle code, either RC or ARC. Otherwise it should calculate as described above.

*****Code******

WhilePrintingRecords;
Global StringVar ItemsOutputArr1;
// other variables left out for brevity, I have more than one output array

if IsNull({USERTABLE.JOBTITLE}) or not ({USERTABLE.JOBTITLE}='RC' or {USERTABLE.JOBTITLE}='ARC') then (

//Calculating the output string runs

);

******End Code*******

I have also put a simple test formula in the same footer as my main formula, the items footer, to test my if conditions. When my jobtitle is blank, or null in the database:
If the test formula is NOT({USERTABLE.JOBTITLE}='RC') the value returned is blank.
If the test formula is: IsNull({USERTABLE.JOBTITLE}) the value returned is true.
If the test formula is: {USERTABLE.JOBTITLE}='ARC' the value returned is blank.
If the test formula is: not({USERTABLE.JOBTITLE}='ARC') the value returned is blank.
If the test formula is: not ({USERTABLE.JOBTITLE}='RC' or {USERTABLE.JOBTITLE}='ARC') the value returned is blank.

How can I make this statement evaluate correctly so it will return true and false like I think it's supposed to?

Please let me know if you have any ideas! Thank you!
 
We need to see the entire formula to help, I think.

-LB
 
There seems to be some conflicting statements in your test formula, but to return boolean arguments you can follow this kind of approach:

If IsNull({USERTABLE.JOBTITLE}) or
Not ({USERTABLE.JOBTITLE} in ['RC','ARC'])
Then False
Else True;

Naith
 
Naith, your solution worked perfectly, thank you very very very much!!!!

I'm not sure what you mean by confilicting statments. I ran the test formula several times and the results were for one user who had no jobtitle at all, each with different run with a different section of the condition as shown. Hope this clarifies things.

Thanks everyone!
 
I'm sorry, you're right; there are no conflicting statements. I'd just read your initial post incorrectly.

I thought opposite statements like
Code:
{USERTABLE.JOBTITLE}='ARC'
and
Code:
not {USERTABLE.JOBTITLE}='ARC'
were part of the same formula, which they're clearly not. Apologies for that.

Naith
 
Crystal's default assumption is to show nothing when it finds a null. I had a lot of trouble with this when I first started using it.

Madawc Williams
East Anglia, Great Britain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top