Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case formula error

Status
Not open for further replies.

terenceb

Programmer
Jun 10, 2003
77
US
Hi All,

I am using crystal 8.5 pulling data from SQL tables in a Cashe database. I am using the case statement below. And I continue to get that " the remaining text does not appear to be apart of the formula." the message points at the following position. "ProdUnits := (Mins / 60);"


whileprintingrecords;
numbervar ProdUnits;
numbervar Mins := {tx_history_all.service_duration};

if {@CPT Eligible} = 'Y' then
if {tx_history_all.SERVICE_CODE} in ['P102', 'P108', 'P109', 'P130', 'P131', 'P133' TO 'P139', 'P142', 'P208', 'P209', 'P9805', 'PM108', 'PM109', 'PM208', 'PM209'] then
select {tx_history_all.service_duration} case 0 to 19 : Mins := 0
case 20 to 44 : Mins := 30
case 45 to 74 : Mins := 50
default : Mins := 80;
else
if not {tx_history_all.SERVICE_CODE} in ['P102', 'P108', 'P109', 'P130', 'P131', 'P133' TO 'P139', 'P142', 'P208', 'P209', 'P9805', 'PM108', 'PM109', 'PM208', 'PM209'] then
select {tx_history_all.service_duration} case 0 to 14 : Mins := 0
case 15 to 29 : Mins := 15
case 30 to 44 : Mins := 30
case 45 to 59 : Mins := 45
case 60 to 74 : Mins := 60
default : Mins := 75;

ProdUnits := (Mins / 60);

ProdUnits;

 
Add another semicolon to the line right before ProdUnits := (Mins / 60); so that it reads
default : Mins := 75;;
 
Try the following (added parens to the sub IF's and the NOT clause):

whileprintingrecords;
numbervar ProdUnits;
numbervar Mins := {tx_history_all.service_duration};

if {@CPT Eligible} = 'Y' then
(
if {tx_history_all.SERVICE_CODE} in ['P102', 'P108', 'P109', 'P130', 'P131', 'P133' TO 'P139', 'P142', 'P208', 'P209', 'P9805', 'PM108', 'PM109', 'PM208', 'PM209'] then
select {tx_history_all.service_duration} case 0 to 19 : Mins := 0
case 20 to 44 : Mins := 30
case 45 to 74 : Mins := 50
default : Mins := 80;
else
if not ({tx_history_all.SERVICE_CODE} in ['P102', 'P108', 'P109', 'P130', 'P131', 'P133' TO 'P139', 'P142', 'P208', 'P209', 'P9805', 'PM108', 'PM109', 'PM208', 'PM209']) then
select {tx_history_all.service_duration} case 0 to 14 : Mins := 0
case 15 to 29 : Mins := 15
case 30 to 44 : Mins := 30
case 45 to 59 : Mins := 45
case 60 to 74 : Mins := 60
default : Mins := 75;
);
ProdUnits := (Mins / 60);

ProdUnits
 
You probably may have to add the NumberVar infront of the ProdUnits.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top