Solved

Crystal report with if statement & Variable not working

Posted on 2010-11-15
7
662 Views
Last Modified: 2012-05-10
Hi,

I have a crystal report (crystal reports basic 2008) thats referencing a microsoft access 2003 query named: " qry_CRYSTAL_REP_FORECAST_PARTCODE" as its data source. Within the report I have a formular field with the below code: The problem is when i try to save and close the formualr the software says: "The remaining text does not appear to be part of the formular" so i guess the syntax i have is incorrect but im not sure what needs to be changed to fix?, please help

numbervar pdact;
numbervar promoqty;

pdact = {qry_CRYSTAL_REP_FORECAST_PARTCODE.PD1ACT}
promoqty = {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY}

if {qry_CRYSTAL_REP_FORECAST_PARTCODE.ACTUALS_TO_PD}>0
    then pdact
    else if {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_INCL_BASE}=0 AND {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY}>0
    then promoqty
//if criteria not met above then use the below for field
else {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_BASE_QTY} + promoqty
0
Comment
Question by:kevin1983
  • 4
  • 3
7 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 34135255
Some essentials about Crystal syntax..

Every statement apart from the final one must be terminated with a ;
Assignment uses := not just = (which is only used for testing a value).

numbervar pdact;
numbervar promoqty;

pdact := {qry_CRYSTAL_REP_FORECAST_PARTCODE.PD1ACT};
promoqty := {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY};

if {qry_CRYSTAL_REP_FORECAST_PARTCODE.ACTUALS_TO_PD}>0
    then pdact
else if {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_INCL_BASE}=0 AND {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY}>0
    then promoqty
//if criteria not met above then use the below for field
else {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_BASE_QTY} + promoqty
0
 

Author Comment

by:kevin1983
ID: 34135273
ok thanks for your comments. I tried what you suggested but it says a boolean is required when i try to save and highlights the 0 on this line

 else if {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_INCL_BASE}=0
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34135370
what is the datatype of {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_INCL_BASE}
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:kevin1983
ID: 34135380
The datatype is: Yes/No
0
 
LVL 77

Expert Comment

by:peter57r
ID: 34135410
Then you can't test for 0 you must test for False
0
 

Author Comment

by:kevin1983
ID: 34135443
ok thats great thanks changed to false and seems to work fine now.
(I now have the below)

numbervar pdact;
numbervar promoqty;

pdact := {qry_CRYSTAL_REP_FORECAST_PARTCODE.PD1ACT};
promoqty := {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY};

if {qry_CRYSTAL_REP_FORECAST_PARTCODE.ACTUALS_TO_PD}>0
    then pdact

else if {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_INCL_BASE}=false AND {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_PROMO_QTY}>0
    then promoqty
//If criteria not met above then use the below for field
else {qry_CRYSTAL_REP_FORECAST_PARTCODE.FORECAST_1_BASE_QTY} + promoqty
0
 

Author Closing Comment

by:kevin1983
ID: 34135451
Thanks a lot
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL Server R2 Stored procedure performance 8 42
combine an MS SQL string in Idera DM 9 48
Help writing a query 6 70
MS SQL Inner Join - Multiple Join Parameters 2 17
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
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 …
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

11 Experts available now in Live!

Get 1:1 Help Now