Solved

Crystal report with if statement & Variable not working

Posted on 2010-11-15
7
661 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

22 Experts available now in Live!

Get 1:1 Help Now