Avatar of Michael Graham
Michael Graham
Flag for United States of America asked on

"A string is required here" error in Formula

Hello,

I am getting the above error when I run this formula:

{vw_reporting_biannualaudit.Drug Schedule}={?@Drug_Schedule}

and  

if  isnull({?@Drug_Schedule}) or not numerictext({?@Drug_Schedule}) then
       0
else
       tonumber({?@Drug_Schedule})

The last part of the formula (tonumber({?@Drug_Schedule}) gives the error.

I have set the @Drug_Schedule parameter to number.

If I set the @Drug_Schedule  parameter to a string it will give me the error "A number is required here" at the top of the formula for the @Drug_Schedule so either way I get an error.

Thanks for any help,

Mike
Crystal Reports

Avatar of undefined
Last Comment
Michael Graham

8/22/2022 - Mon
Mike McCracken

Where are you trying to use this formula?

Are there 2 formulas there or is the full formula

{vw_reporting_biannualaudit.Drug Schedule}={?@Drug_Schedule}

 and  

 if  isnull({?@Drug_Schedule}) or not numerictext({?@Drug_Schedule}) then 
        0
 else
        tonumber({?@Drug_Schedule})

Open in new window


If the parameter is a number then you can't convert it to a number.
If it is a number then it can't have non-numeric text in it.

What are you trying to do with the formula?  If what I put in the text box is the full formula then you will get another error because the AND wants a Boolean.

If there are 2 formulas then change the second one to

 if  isnull({?@Drug_Schedule}) then 
        0
 else
        {?@Drug_Schedule}

Open in new window


mlmcc
Michael Graham

ASKER
I am still trying to achieve the Parameter Drug Schedule to return all records when nothing is entered.  This is very easy when I set the Parameter to optional.  I am only using 1 parameter for Drug Schedule now.

We are new to automation in Crystal Reports via Business Objects.

On the dashboard the Parameter will appear at the top and nothing needs to be entered which is what I want (again if I set the parameter to optional prompt).

However, when I run the report it will prompt me to enter a value like it would in the native crystal report.  I do not have to enter a value (I can leave it blank) but I do not want this prompt to show up.
Mike McCracken

So this is the selection formula?

I believe you will need to either have no parameter or write your own viewer.

Are you running the report in the dashboard or separately?

mlmcc
Your help has saved me hundreds of hours of internet surfing.
fblack61
Michael Graham

ASKER
Yes this is the selection formula.

I am running it in the dashboard - however I am only allowed to edit it in the report.

I am not sure how to run my own viewer
SOLUTION
Mike McCracken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
James0628

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Michael Graham

ASKER
Thanks everyone I finally figured it out - I had to keep working on the formulas you gave me.  You have taught me a lot while I am just starting out in Crystal.  I appreciate all the help.