Link to home
Start Free TrialLog in
Avatar of Sue Taylor
Sue TaylorFlag for United States of America

asked on

A string is required here error

I can't figure out why I'm getting 'A string is required here' error in my formula and require assistance.  I'm using CR 2008



The error is when I test my formula called "Outage" which is:
 ({@MainReportVariable}+ ({p21_view_inv_loc.order_quantity}))/({p21_view_inv_loc.inv_min}*6)
{p21_view_inv_loc.order_quantity} is the item that is highlighted and is a number field.  I need it to be a number field in order to perform some basic math in my report.

My subreport called "Available" has a formula called "SubReportVariable" which is:
Shared numbervar Tot;
tot:=Sum ({@Available})
--mail-staylor--Custom-Reports-Purch.rpt
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Hi,
Pls try like..

tot:=
SUM
(
if  IsNull ({@Available}) or not NumericText ({@Available}) then
       0
else
       ToNumber ({@Available})
)

Open in new window


Hope it helps!
Avatar of Sue Taylor

ASKER

I'm not sure exactly where I was supposed to try that but I created  new formula in the subreport and got errors when checking it.  Please provide more details.
Replace your existing formula with the formula I gave. Do not create a new one.
Replace which formula?  The one called "Outage"?  I did that and got ' The remaining text does not appear to be part of the formula' error
Replace

tot:=Sum ({@Available})

with below-

tot:=
SUM
(
if  IsNull ({@Available}) or not NumericText ({@Available}) then
       0
else
       ToNumber ({@Available})
)
I get an error 'A string is required here' and it highlights ({Available}) when I check the formula
It highlights the second Available
Do you have NULL, ABC kind of characters in that column apart from Numbers?
Try this then

tot:=
SUM
(
if  IsNull ({@Available}) or not NumericText ({@Available}) then
       0
else
       {@Available}
)
It errors on the second ({Available}) that's in the [ or not NumbercText ]

So I took the parenthesis off of that one and then the error changed to the key word 'then' is missing, but it is clearly there.
I forgot....all of the fields that I am summing in the formula are number fields.  Not text  Yes they could be null.
Please try ..

tot:=
SUM
(
if  IsNull ({@Available})  THEN  0 else ({@Available})
)
A field is required here and the entire If line is highlighted.
Please check if this works?

tot:=
(
if  IsNull ({@Available})  THEN  0 else ({@Available})
)
No errors this time!  Yay!    But when I check the "outage" formula I still get an error 'A string is required here' and it highlights the ({p21_view_loc.order_quantity})

({@MainReportVariable}+ ({p21_view_inv_loc.order_quantity}))/({p21_view_inv_loc.inv_min}*6)
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This is my MainReportVariable...


Shared numbervar Tot;
""

Isn't that a number?
Avatar of Mike McCracken
Mike McCracken

No it returns the empty string.  Delete the ""

mlmcc
Thanks mlmcc!
I fixed the original error and no points? Sad :(