cancel
Showing results for 
Search instead for 
Did you mean: 

A number is required here

former_member1107312
Participant
0 Kudos

Hello,

I have a formula here for a sub report that check from my main report for values here.

If the value from main report (SDay1) if it's a positive number then I want to put this value in "-" if that number is negative then I want to add in from another variable (WIPMAIN and divided from number in the database)

Here is my formula:

WhilePrintingRecords;

Shared Numbervar SDay1;

Shared Numbervar WDay1;

Shared Numbervar WIPMAIN;

Shared Numbervar WTemp1;

Shared Stringvar STemp;

If (Sday1 > 0)  Then   

     (   

     WTemp1 := (WIPMAIN / {V_STRUC_HDR_COMP_ISS_DATA.COMP_PART_QTY_PER_ASSEMBLY})+ Sday1;  //Place holder need for other   calculations    

     WDay1 := 0   

     )

Else   

     (    

     If (WIPMAIN =0) Then       

          WDAY1 := 0   

     Else       

          WDay1 := (WIPMAIN / {V_STRUC_HDR_COMP_ISS_DATA.COMP_PART_QTY_PER_ASSEMBLY})+ Sday1

     );

I tried this on the first if statment

If (Sday1 > 0) then

     (

     WTemp1 : = the same as above .....

     WDay1 := totext("-")

it gives me an error saying it requires a number here.

I tried to replace totext to CSTR, same error.

If anyone can help I would appreciated it.

Regards,
Gerald

Accepted Solutions (1)

Accepted Solutions (1)

former_member205840
Active Contributor
0 Kudos

Hi Gerald,

If you look at the below code, you are trying to assign a text value to a numeric variable. Either you have to change variable data type or assign 0 instead of  -



If (Sday1 > 0) then

     (

     WTemp1 : = the same as above .....

     WDay1 := totext("-")



Thanks,

Sastry

former_member1107312
Participant
0 Kudos

Same error message there..  A number is required.

former_member205840
Active Contributor
0 Kudos

Hi Gerald,

Then don't try to modify the existing formula, suppose the formula name is 'Calculation' then do below

If {@Calculation} > 0  Then '-'

Else

ToText(Do all your calculations here)

This will not give you any error.

Thanks,

Sastry

former_member1107312
Participant
0 Kudos

Hello,

So I left my existing formula along and then created a new formula referring to variables from the first formula and assign variable as string values.  Then use the totext(var) and it worked.

Thank you everyone here giving me some ideas.

Answers (2)

Answers (2)

former_member280812
Active Participant
0 Kudos

Hi Gerald,

I think crystal report formula does not allow you to do that because you are trying to  assign string value to a number data type.

If you just want to display "-" in your output then i think you can try to use another formula on that.

Regards,

Eric

abhilash_kumar
Active Contributor
0 Kudos

Hi Gerald,

You'd need to make sure that the variable 'WDay1' returns text in every part of the if-else loop.

-Abhilash

former_member1107312
Participant
0 Kudos

I tried that and it still gave me the same message... A number is required here.