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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error - A number is required - works in v8.5 and not in v10

Status
Not open for further replies.

jraheja

Technical User
Oct 12, 2004
176
US
Following code works in v 8.5 but gives error in v10 - number is required at location "perc:= Round((Sum ({@inc1}) / ToNumber ({@amt_display}) * 100) - 100,0)" ...Why?
----------------------------------------

stringvar percent;
numbervar perc;

if {@amt_display} <> 0 AND Sum ({@inc1}) <> 0
then perc:= Round((Sum ({@inc1}) / ToNumber ({@amt_display}) * 100) - 100,0)
else if {@amt_display} = 0 AND Sum ({@inc1}) = 0
then perc:=0
else if {@amt_display} = 0
then perc:=100
else if Sum ({@inc1}) = 0
then perc:=0;

percent :=ToText(truncate(perc),0) + " %
 
I'm not an expert on variables - I prefer to use formual fields - but since no one else has answered, I'll have a go.

I'm suspicious first of the percent :=ToText(truncate(perc),0) + " %" at the end. Try commenting it out - put // in front - and see if that works.

The other thought I had was to change 100) - 100,0) to 100) - 100, 0); new versions of software are often fussier about grammer.


[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
What are the variable types for @AmtDisplay and @Inc1 as this may be the problem if they are not numerics ?

ShortyA
 
Hi guys! The last statement does not give errors. The ; did not help. I have noted the error is at runtime. Can it be a data error???

@amt_display is defined as -
WhilePrintingRecords;
CurrencyVar Amount;

@inc1 is defined as
if Year({Prod_Trans.Prod_Trans_Dte}) = {@year} and
Month({Prod_Trans.Prod_Trans_Dte}) = {@mon1}
then {Prod_Trans.Clb_Comm_Amt}
else 0

Both did not give compiling errors...
 
Is it possible for {Prod_Trans.Clb_Comm_Amt} to be null?

If there isn't a NOT NULL constraint applied at a database level, try prefixing your formula with:

if
(
isnull({Prod_Trans.Clb_Comm_Amt}) and
Year({Prod_Trans.Prod_Trans_Dte}) = {@year} and
Month({Prod_Trans.Prod_Trans_Dte}) = {@mon1}
)
then 0
else
if Year({Prod_Trans.Prod_Trans_Dte}) = {@year} and
Month({Prod_Trans.Prod_Trans_Dte}) = {@mon1}
then {Prod_Trans.Clb_Comm_Amt}
else 0

Additionally, run the same check and fix against your date field.

Naith
 
I tried this and it still gave me error. Is it wrong??? This is someone else's code and database and I am maintaining it now - the reports...

if
(
isnull({Prod_Trans.Clb_Comm_Amt}) and
Year({Prod_Trans.Prod_Trans_Dte}) = {@year} and
Month({Prod_Trans.Prod_Trans_Dte}) = {@mon1}
)
then 0
else
if
(isnull ({Prod_Trans.Prod_Trans_Dte})) then 0
else
if
Year({Prod_Trans.Prod_Trans_Dte}) = {@year} and
Month({Prod_Trans.Prod_Trans_Dte}) = {@mon1}
then {Prod_Trans.Clb_Comm_Amt}
else 0
 
Have you also tested for null values against the datefield and {@amt_display}?
 
@amt_display as stated aerler just had a declaration. Date I have checked above "if
(isnull ({Prod_Trans.Prod_Trans_Dte})) then 0"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top