Solved

# IF THEN LOOP

Posted on 2014-04-02
170 Views
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}
``````

Iam getting error saying ')' is missing not sure where Iam missing.
Thanks.
0
Question by:Star79

LVL 22

Expert Comment

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

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}
``````

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}
``````

mlmcc
0

## Featured Post

### Suggested Solutions

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …