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

Using the Or operator in Formulas on Version 8 1

Status
Not open for further replies.

Jjackstraw

Programmer
Apr 17, 2001
8
US
I have a report linked to tables in a SQL Server database. I have two fields called PaymentAmount and DepAmount. (The fields are Float datatypes).
They are to distinguish between a Deposit and Payment. If the transaction was a Deposit - the payment is NULL and vice-versa so one will always be NULL and one will always have a value.. For some records the Amount (either deposit or payment) is zero. I want to suppress these records.
I have the following in my record suppression formula:

({RRPostingHistory.PaymentAmount} > 0) or ({RRPostingHistory.DepAmount} > 0)

It doesn't work right - it suppresses ALL of the Deposit Amounts. What makes me insane is that if I reverse them:

({RRPostingHistory.DepAmount} > 0) or
({RRPostingHistory.PaymentAmount} > 0)

it then suppresses all of the Payment amounts. How can this be. In Logic class in high school we learned
(A or B) = (B or A)
Apparently CR v8 has never attended a Logic class.

Is there anyone who can give me a workaround or SOMETHING?
Thanks for you time.
 
The problem is that databases often require tri value logic - True, False, Unknown (also known as NULL).
So, if you have null amounts in DepAmount or PaymentAmount, then the formula can potentially return an "Unknown" as a logical result. For example, False or Null is logically "Unknown". One of the limitations/features of Crystal Reports is that it doesn't like producing NULL as a formula result - and if you think about it, it is not a useful result to have when making a decision whether to suppress a record.
You can convert Null values to a default in File|Report Options. If your database has a default value for that field, then this will work.
Otherwise, the solution is use the IsNull() function in your formula, something like
((Not IsNull(DepAmount)) and DepAmount > 0) or
((Not IsNull(PaymentAmount)) and PaymentAmount > 0)
Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top