Solved

IF THEN LOOP

Posted on 2014-04-02
2
174 Views
Last Modified: 2014-04-02
Hello,
I have below if loop in crystal formula:

if {Non_FormularyDrugReporttest;1.Action}= 'D' then
{Non_FormularyDrugReporttest;1.Qty}
ELSE  
if (isnull ({Non_FormularyDrugReporttest;1.Action})= true 
 then
{Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}
ELSE
if {Non_FormularyDrugReporttest;1.Action} = 'R' then

{Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}

Open in new window


Iam getting error saying ')' is missing not sure where Iam missing.
Thanks.
0
Comment
Question by:Star79
2 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39972691
if {Non_FormularyDrugReporttest;1.Action}= 'D' then
{Non_FormularyDrugReporttest;1.Qty}
ELSE  
if (isnull ({Non_FormularyDrugReporttest;1.Action})= true )
 then
{Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}
ELSE
if {Non_FormularyDrugReporttest;1.Action} = 'R' then

{Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39972788
You need to change the formula to test for NULL first.  Crystal errors out when it uses a NULL value in a test other than IsNull

if (isnull ({Non_FormularyDrugReporttest;1.Action})= true ) then
     {Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}
ELSE if {Non_FormularyDrugReporttest;1.Action}= 'D' then
     {Non_FormularyDrugReporttest;1.Qty}
ELSE if {Non_FormularyDrugReporttest;1.Action} = 'R' then
     {Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty} 

Open in new window


You can also eliminate the comparison to TRUE for the IsNull test

if IsNull ({Non_FormularyDrugReporttest;1.Action}) then
     {Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty}
ELSE if {Non_FormularyDrugReporttest;1.Action}= 'D' then
     {Non_FormularyDrugReporttest;1.Qty}
ELSE if {Non_FormularyDrugReporttest;1.Action} = 'R' then
     {Non_FormularyDrugReporttest;1.Qty}  - {Non_FormularyDrugReporttest;1.creditqty} 

Open in new window


mlmcc
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question