Solved

IF THEN LOOP

Posted on 2014-04-02
2
170 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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: …

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now